You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/07/10 14:00:15 UTC

[incubator-nuttx] branch master updated: libc/math: Add fmax and fmin functions

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

acassis 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 012158c  libc/math: Add fmax and fmin functions
012158c is described below

commit 012158cce809ef509560642dac421f021f952e2c
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Sat Jul 10 21:03:05 2021 +0900

    libc/math: Add fmax and fmin functions
    
    Add fmax and fmin functions.
    - fmax, fmaxf, fmaxl
    - fmin, fminf, fminl
---
 libs/libc/math/Make.defs   |  2 ++
 libs/libc/math/lib_fmax.c  | 39 +++++++++++++++++++++++++++++++++++++++
 libs/libc/math/lib_fmaxf.c | 37 +++++++++++++++++++++++++++++++++++++
 libs/libc/math/lib_fmaxl.c | 39 +++++++++++++++++++++++++++++++++++++++
 libs/libc/math/lib_fmin.c  | 39 +++++++++++++++++++++++++++++++++++++++
 libs/libc/math/lib_fminf.c | 37 +++++++++++++++++++++++++++++++++++++
 libs/libc/math/lib_fminl.c | 39 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 232 insertions(+)

diff --git a/libs/libc/math/Make.defs b/libs/libc/math/Make.defs
index d4e30c8..5ea034d 100644
--- a/libs/libc/math/Make.defs
+++ b/libs/libc/math/Make.defs
@@ -52,6 +52,8 @@ 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 += lib_fmax.c lib_fmaxf.c lib_fmaxl.c
+CSRCS += lib_fmin.c lib_fminf.c lib_fminl.c
 
 CSRCS += __cos.c __sin.c lib_gamma.c lib_lgamma.c
 
diff --git a/libs/libc/math/lib_fmax.c b/libs/libc/math/lib_fmax.c
new file mode 100644
index 0000000..1cb62c0
--- /dev/null
+++ b/libs/libc/math/lib_fmax.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * libs/libc/math/lib_fmax.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 fmax(double x, double y)
+{
+  return ((x > y) ? x : y);
+}
+#endif
diff --git a/libs/libc/math/lib_fmaxf.c b/libs/libc/math/lib_fmaxf.c
new file mode 100644
index 0000000..1e545aa
--- /dev/null
+++ b/libs/libc/math/lib_fmaxf.c
@@ -0,0 +1,37 @@
+/****************************************************************************
+ * libs/libc/math/lib_fmaxf.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 fmaxf(float x, float y)
+{
+  return ((x > y) ? x : y);
+}
diff --git a/libs/libc/math/lib_fmaxl.c b/libs/libc/math/lib_fmaxl.c
new file mode 100644
index 0000000..ae7a278
--- /dev/null
+++ b/libs/libc/math/lib_fmaxl.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * libs/libc/math/lib_fmaxl.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 fmaxl(long double x, long double y)
+{
+  return ((x > y) ? x : y);
+}
+#endif
diff --git a/libs/libc/math/lib_fmin.c b/libs/libc/math/lib_fmin.c
new file mode 100644
index 0000000..c494575
--- /dev/null
+++ b/libs/libc/math/lib_fmin.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * libs/libc/math/lib_fmin.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 fmin(double x, double y)
+{
+  return ((x < y) ? x : y);
+}
+#endif
diff --git a/libs/libc/math/lib_fminf.c b/libs/libc/math/lib_fminf.c
new file mode 100644
index 0000000..1ba6edf
--- /dev/null
+++ b/libs/libc/math/lib_fminf.c
@@ -0,0 +1,37 @@
+/****************************************************************************
+ * libs/libc/math/lib_fminf.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 fminf(float x, float y)
+{
+  return ((x < y) ? x : y);
+}
diff --git a/libs/libc/math/lib_fminl.c b/libs/libc/math/lib_fminl.c
new file mode 100644
index 0000000..22e74ce
--- /dev/null
+++ b/libs/libc/math/lib_fminl.c
@@ -0,0 +1,39 @@
+/****************************************************************************
+ * libs/libc/math/lib_fminl.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 fminl(long double x, long double y)
+{
+  return ((x < y) ? x : y);
+}
+#endif