shithub: riscv

Download patch

ref: be3809866ce89d2dcac0b02f2ec7b49b5393cb56
parent: 930efe67e81635e632f1e6f93e1c56499c79a55f
author: aiju <devnull@localhost>
date: Thu May 24 09:40:44 EDT 2018

ape: floating point improvements (thanks spew)

--- a/386/include/ape/math.h
+++ b/386/include/ape/math.h
@@ -15,6 +15,7 @@
 extern double atan(double);
 extern double atan2(double, double);
 extern double cos(double);
+extern double hypot(double, double);
 extern double sin(double);
 extern double tan(double);
 extern double cosh(double);
@@ -36,6 +37,7 @@
 extern int isNaN(double);
 extern double Inf(int);
 extern int isInf(double, int);
+extern double fmin(double, double);
 
 #ifdef _RESEARCH_SOURCE
 /* does >> treat left operand as unsigned ? */
--- a/68020/include/ape/math.h
+++ b/68020/include/ape/math.h
@@ -15,6 +15,7 @@
 extern double atan(double);
 extern double atan2(double, double);
 extern double cos(double);
+extern double hypot(double, double);
 extern double sin(double);
 extern double tan(double);
 extern double cosh(double);
@@ -36,6 +37,7 @@
 extern int isNaN(double);
 extern double Inf(int);
 extern int isInf(double, int);
+extern double fmin(double, double);
 
 #ifdef _RESEARCH_SOURCE
 /* does >> treat left operand as unsigned ? */
--- a/amd64/include/ape/math.h
+++ b/amd64/include/ape/math.h
@@ -37,6 +37,7 @@
 extern int isNaN(double);
 extern double Inf(int);
 extern int isInf(double, int);
+extern double fmin(double, double);
 
 #ifdef _RESEARCH_SOURCE
 /* does >> treat left operand as unsigned ? */
--- a/arm/include/ape/math.h
+++ b/arm/include/ape/math.h
@@ -15,6 +15,7 @@
 extern double atan(double);
 extern double atan2(double, double);
 extern double cos(double);
+extern double hypot(double, double);
 extern double sin(double);
 extern double tan(double);
 extern double cosh(double);
@@ -36,6 +37,7 @@
 extern int isNaN(double);
 extern double Inf(int);
 extern int isInf(double, int);
+extern double fmin(double, double);
 
 #ifdef _RESEARCH_SOURCE
 /* does >> treat left operand as unsigned ? */
--- a/mips/include/ape/math.h
+++ b/mips/include/ape/math.h
@@ -15,6 +15,7 @@
 extern double atan(double);
 extern double atan2(double, double);
 extern double cos(double);
+extern double hypot(double, double);
 extern double sin(double);
 extern double tan(double);
 extern double cosh(double);
@@ -36,6 +37,7 @@
 extern int isNaN(double);
 extern double Inf(int);
 extern int isInf(double, int);
+extern double fmin(double, double);
 
 #ifdef _RESEARCH_SOURCE
 /* does >> treat left operand as unsigned ? */
--- a/power/include/ape/math.h
+++ b/power/include/ape/math.h
@@ -15,6 +15,7 @@
 extern double atan(double);
 extern double atan2(double, double);
 extern double cos(double);
+extern double hypot(double, double);
 extern double sin(double);
 extern double tan(double);
 extern double cosh(double);
@@ -36,6 +37,7 @@
 extern int isNaN(double);
 extern double Inf(int);
 extern int isInf(double, int);
+extern double fmin(double, double);
 
 #ifdef _RESEARCH_SOURCE
 /* does >> treat left operand as unsigned ? */
--- a/sparc/include/ape/math.h
+++ b/sparc/include/ape/math.h
@@ -15,6 +15,7 @@
 extern double atan(double);
 extern double atan2(double, double);
 extern double cos(double);
+extern double hypot(double, double);
 extern double sin(double);
 extern double tan(double);
 extern double cosh(double);
@@ -36,6 +37,7 @@
 extern int isNaN(double);
 extern double Inf(int);
 extern int isInf(double, int);
+extern double fmin(double, double);
 
 #ifdef _RESEARCH_SOURCE
 /* does >> treat left operand as unsigned ? */
--- a/sparc64/include/ape/math.h
+++ b/sparc64/include/ape/math.h
@@ -15,6 +15,7 @@
 extern double atan(double);
 extern double atan2(double, double);
 extern double cos(double);
+extern double hypot(double, double);
 extern double sin(double);
 extern double tan(double);
 extern double cosh(double);
@@ -36,6 +37,7 @@
 extern int isNaN(double);
 extern double Inf(int);
 extern int isInf(double, int);
+extern double fmin(double, double);
 
 #ifdef _RESEARCH_SOURCE
 /* does >> treat left operand as unsigned ? */
--- /dev/null
+++ b/sys/src/ape/lib/ap/math/fmin.c
@@ -1,0 +1,11 @@
+#include <math.h>
+
+double
+fmin(double a, double b)
+{
+	if(isNaN(a))
+		return b;
+	if(isNaN(b))
+		return a;
+	return a < b ? a : b;
+}
--- a/sys/src/ape/lib/ap/math/mkfile
+++ b/sys/src/ape/lib/ap/math/mkfile
@@ -10,6 +10,7 @@
 	fabs.$O\
 	floor.$O\
 	fmod.$O\
+	fmin.$O\
 	gamma.$O\
 	hypot.$O\
 	j0.$O\