Index: uspace/app/tester/float/softfloat1.c
===================================================================
--- uspace/app/tester/float/softfloat1.c	(revision 7218fe6b2a633b85c30cc17b7392712ed1b9163c)
+++ uspace/app/tester/float/softfloat1.c	(revision c86ca9a21081d254a444d9cc9618a9d121e7b786)
@@ -29,5 +29,5 @@
 #include <stdio.h>
 #include <stdlib.h>
-#include <sftypes.h>
+#include <mathtypes.h>
 #include <add.h>
 #include <sub.h>
@@ -39,6 +39,28 @@
 #include "../tester.h"
 
+#define add_float  __addsf3
+#define sub_float  __subsf3
+#define mul_float  __mulsf3
+#define div_float  __divsf3
+
+#define is_float_lt  __ltsf2
+#define is_float_gt  __gtsf2
+#define is_float_eq  __eqsf2
+
+#define add_double  __adddf3
+#define sub_double  __subdf3
+#define mul_double  __muldf3
+#define div_double  __divdf3
+
+#define is_double_lt  __ltdf2
+#define is_double_gt  __gtdf2
+#define is_double_eq  __eqdf2
+
+#define uint_to_double  __floatsidf
+#define double_to_uint  __fixunsdfsi
+#define double_to_int   __fixdfsi
+
 #define OPERANDS   10
-#define PRECISION  10000
+#define PRECISION  1000
 
 #define PRIdCMPTYPE  PRId32
@@ -46,8 +68,9 @@
 typedef int32_t cmptype_t;
 
-typedef void (* uint_to_double_op_t)(unsigned int, double *, double_t *);
+typedef void (* uint_to_double_op_t)(unsigned int, double *, double *);
 typedef void (* double_to_uint_op_t)(double, unsigned int *, unsigned int *);
-typedef void (* float_binary_op_t)(float, float, float *, float_t *);
-typedef void (* double_binary_op_t)(double, double, double *, double_t *);
+typedef void (* float_binary_op_t)(float, float, float *, float *);
+typedef void (* float_cmp_op_t)(float, float, cmptype_t *, cmptype_t *);
+typedef void (* double_binary_op_t)(double, double, double *, double *);
 typedef void (* double_cmp_op_t)(double, double, cmptype_t *, cmptype_t *);
 
@@ -68,16 +91,8 @@
 
 static unsigned int uop_a[OPERANDS] = {
-	4, -100, 100, 50, 1024, 0, 1000000, -1U, 0x80000000U, 500
+	4, 2, 100, 50, 1024, 0, 1000000, 1, 0x8000000, 500
 };
 
-static cmptype_t cmpabs(cmptype_t a)
-{
-	if (a >= 0)
-		return a;
-	
-	return -a;
-}
-
-static int dcmp(double a, double b)
+static int fcmp(float a, float b)
 {
 	if (a < b)
@@ -90,4 +105,15 @@
 }
 
+static int dcmp(double a, double b)
+{
+	if (a < b)
+		return -1;
+	
+	if (a > b)
+		return 1;
+	
+	return 0;
+}
+
 static void uint_to_double_template(void *f, unsigned i, cmptype_t *pic,
     cmptype_t *pisc)
@@ -96,9 +122,9 @@
 	
 	double c;
-	double_t sc;
+	double sc;
 	op(uop_a[i], &c, &sc);
 	
 	*pic = (cmptype_t) (c * PRECISION);
-	*pisc = (cmptype_t) (sc.val * PRECISION);
+	*pisc = (cmptype_t) (sc * PRECISION);
 }
 
@@ -116,5 +142,4 @@
 }
 
-
 static void float_template_binary(void *f, unsigned i, unsigned j,
     cmptype_t *pic, cmptype_t *pisc)
@@ -123,9 +148,17 @@
 	
 	float c;
-	float_t sc;
+	float sc;
 	op(fop_a[i], fop_a[j], &c, &sc);
 	
 	*pic = (cmptype_t) (c * PRECISION);
-	*pisc = (cmptype_t) (sc.val * PRECISION);
+	*pisc = (cmptype_t) (sc * PRECISION);
+}
+
+static void float_compare_template(void *f, unsigned i, unsigned j,
+    cmptype_t *pis, cmptype_t *piss)
+{
+	float_cmp_op_t op = (float_cmp_op_t) f;
+	
+	op(dop_a[i], dop_a[j], pis, piss);
 }
 
@@ -136,9 +169,9 @@
 	
 	double c;
-	double_t sc;
+	double sc;
 	op(dop_a[i], dop_a[j], &c, &sc);
 	
 	*pic = (cmptype_t) (c * PRECISION);
-	*pisc = (cmptype_t) (sc.val * PRECISION);
+	*pisc = (cmptype_t) (sc * PRECISION);
 }
 
@@ -160,8 +193,9 @@
 		
 		template(f, i, &ic, &isc);
-		cmptype_t diff = cmpabs(ic - isc);
+		cmptype_t diff = ic - isc;
 		
 		if (diff != 0) {
-			TPRINTF("i=%u diff=%" PRIdCMPTYPE "\n", i, diff);
+			TPRINTF("i=%u ic=%" PRIdCMPTYPE " isc=%" PRIdCMPTYPE "\n",
+			    i, ic, isc);
 			correct = false;
 		}
@@ -181,9 +215,9 @@
 			
 			template(f, i, j, &ic, &isc);
-			cmptype_t diff = cmpabs(ic - isc);
+			cmptype_t diff = ic - isc;
 			
 			if (diff != 0) {
-				TPRINTF("i=%u, j=%u diff=%" PRIdCMPTYPE "\n",
-				    i, j, diff);
+				TPRINTF("i=%u, j=%u ic=%" PRIdCMPTYPE
+				    " isc=%" PRIdCMPTYPE "\n", i, j, ic, isc);
 				correct = false;
 			}
@@ -194,8 +228,8 @@
 }
 
-static void uint_to_double_operator(unsigned int a, double *pc, double_t *psc)
+static void uint_to_double_operator(unsigned int a, double *pc, double *psc)
 {
 	*pc = (double) a;
-	psc->data = uint_to_double(a);
+	*psc = uint_to_double(a);
 }
 
@@ -203,10 +237,6 @@
     unsigned int *psc)
 {
-	double_t sa;
-	
-	sa.val = a;
-	
 	*pc = (unsigned int) a;
-	*psc = double_to_uint(sa.data);
+	*psc = double_to_uint(a);
 }
 
@@ -214,130 +244,48 @@
     unsigned int *psc)
 {
-	double_t sa;
-	
-	sa.val = a;
-	
 	*pc = (int) a;
-	*psc = double_to_int(sa.data);
-}
-
-static void float_add_operator(float a, float b, float *pc, float_t *psc)
+	*psc = double_to_int(a);
+}
+
+static void float_add_operator(float a, float b, float *pc, float *psc)
 {
 	*pc = a + b;
-	
-	float_t sa;
-	float_t sb;
-	
-	sa.val = a;
-	sb.val = b;
-	
-	if (sa.data.parts.sign == sb.data.parts.sign) {
-		psc->data = add_float(sa.data, sb.data);
-	} else if (sa.data.parts.sign) {
-		sa.data.parts.sign = 0;
-		psc->data = sub_float(sb.data, sa.data);
-	} else {
-		sb.data.parts.sign = 0;
-		psc->data = sub_float(sa.data, sb.data);
-	}
-}
-
-static void float_mul_operator(float a, float b, float *pc, float_t *psc)
+	*psc = add_float(a, b);
+}
+
+static void float_sub_operator(float a, float b, float *pc, float *psc)
+{
+	*pc = a - b;
+	*psc = sub_float(a, b);
+}
+
+static void float_mul_operator(float a, float b, float *pc, float *psc)
 {
 	*pc = a * b;
-	
-	float_t sa;
-	float_t sb;
-	
-	sa.val = a;
-	sb.val = b;
-	psc->data = mul_float(sa.data, sb.data);
-}
-
-static void float_div_operator(float a, float b, float *pc, float_t *psc)
+	*psc = mul_float(a, b);
+}
+
+static void float_div_operator(float a, float b, float *pc, float *psc)
 {
 	if ((cmptype_t) b == 0) {
 		*pc = 0.0;
-		psc->val = 0.0;
+		*psc = 0.0;
 		return;
 	}
 	
 	*pc = a / b;
-	
-	float_t sa;
-	float_t sb;
-	
-	sa.val = a;
-	sb.val = b;
-	psc->data = div_float(sa.data, sb.data);
-}
-
-static void double_add_operator(double a, double b, double *pc, double_t *psc)
-{
-	*pc = a + b;
-	
-	double_t sa;
-	double_t sb;
-	
-	sa.val = a;
-	sb.val = b;
-	
-	if (sa.data.parts.sign == sb.data.parts.sign) {
-		psc->data = add_double(sa.data, sb.data);
-	} else if (sa.data.parts.sign) {
-		sa.data.parts.sign = 0;
-		psc->data = sub_double(sb.data, sa.data);
-	} else {
-		sb.data.parts.sign = 0;
-		psc->data = sub_double(sa.data, sb.data);
-	}
-}
-
-static void double_mul_operator(double a, double b, double *pc, double_t *psc)
-{
-	*pc = a * b;
-	
-	double_t sa;
-	double_t sb;
-	
-	sa.val = a;
-	sb.val = b;
-	psc->data = mul_double(sa.data, sb.data);
-}
-
-static void double_div_operator(double a, double b, double *pc, double_t *psc)
-{
-	if ((cmptype_t) b == 0) {
-		*pc = 0.0;
-		psc->val = 0.0;
-		return;
-	}
-	
-	*pc = a / b;
-	
-	double_t sa;
-	double_t sb;
-	
-	sa.val = a;
-	sb.val = b;
-	psc->data = div_double(sa.data, sb.data);
-}
-
-static void double_cmp_operator(double a, double b, cmptype_t *pis,
+	*psc = div_float(a, b);
+}
+
+static void float_cmp_operator(float a, float b, cmptype_t *pis,
     cmptype_t *piss)
 {
-	*pis = dcmp(a, b);
-	
-	double_t sa;
-	double_t sb;
-	
-	sa.val = a;
-	sb.val = b;
-	
-	if (is_double_lt(sa.data, sb.data))
+	*pis = fcmp(a, b);
+	
+	if (is_float_lt(a, b) == -1)
 		*piss = -1;
-	else if (is_double_gt(sa.data, sb.data))
+	else if (is_float_gt(a, b) == 1)
 		*piss = 1;
-	else if (is_double_eq(sa.data, sb.data))
+	else if (is_float_eq(a, b) == 0)
 		*piss = 0;
 	else
@@ -345,61 +293,124 @@
 }
 
+static void double_add_operator(double a, double b, double *pc, double *psc)
+{
+	*pc = a + b;
+	*psc = add_double(a, b);
+}
+
+static void double_sub_operator(double a, double b, double *pc, double *psc)
+{
+	*pc = a - b;
+	*psc = sub_double(a, b);
+}
+
+static void double_mul_operator(double a, double b, double *pc, double *psc)
+{
+	*pc = a * b;
+	*psc = mul_double(a, b);
+}
+
+static void double_div_operator(double a, double b, double *pc, double *psc)
+{
+	if ((cmptype_t) b == 0) {
+		*pc = 0.0;
+		*psc = 0.0;
+		return;
+	}
+	
+	*pc = a / b;
+	*psc = div_double(a, b);
+}
+
+static void double_cmp_operator(double a, double b, cmptype_t *pis,
+    cmptype_t *piss)
+{
+	*pis = dcmp(a, b);
+	
+	if (is_double_lt(a, b) == -1)
+		*piss = -1;
+	else if (is_double_gt(a, b) == 1)
+		*piss = 1;
+	else if (is_double_eq(a, b) == 0)
+		*piss = 0;
+	else
+		*piss = 42;
+}
+
 const char *test_softfloat1(void)
 {
-	const char *err = NULL;
+	bool err = false;
 	
 	if (!test_template_binary(float_template_binary, float_add_operator)) {
-		err = "Float addition failed";
-		TPRINTF("%s\n", err);
+		err = true;
+		TPRINTF("%s\n", "Float addition failed");
+	}
+	
+	if (!test_template_binary(float_template_binary, float_sub_operator)) {
+		err = true;
+		TPRINTF("%s\n", "Float addition failed");
 	}
 	
 	if (!test_template_binary(float_template_binary, float_mul_operator)) {
-		err = "Float multiplication failed";
-		TPRINTF("%s\n", err);
+		err = true;
+		TPRINTF("%s\n", "Float multiplication failed");
 	}
 	
 	if (!test_template_binary(float_template_binary, float_div_operator)) {
-		err = "Float division failed";
-		TPRINTF("%s\n", err);
+		err = true;
+		TPRINTF("%s\n", "Float division failed");
+	}
+	
+	if (!test_template_binary(float_compare_template, float_cmp_operator)) {
+		err = true;
+		TPRINTF("%s\n", "Float comparison failed");
 	}
 	
 	if (!test_template_binary(double_template_binary, double_add_operator)) {
-		err = "Double addition failed";
-		TPRINTF("%s\n", err);
+		err = true;
+		TPRINTF("%s\n", "Double addition failed");
+	}
+	
+	if (!test_template_binary(double_template_binary, double_sub_operator)) {
+		err = true;
+		TPRINTF("%s\n", "Double addition failed");
 	}
 	
 	if (!test_template_binary(double_template_binary, double_mul_operator)) {
-		err = "Double multiplication failed";
-		TPRINTF("%s\n", err);
+		err = true;
+		TPRINTF("%s\n", "Double multiplication failed");
 	}
 	
 	if (!test_template_binary(double_template_binary, double_div_operator)) {
-		err = "Double division failed";
-		TPRINTF("%s\n", err);
+		err = true;
+		TPRINTF("%s\n", "Double division failed");
 	}
 	
 	if (!test_template_binary(double_compare_template, double_cmp_operator)) {
-		err = "Double comparison failed";
-		TPRINTF("%s\n", err);
+		err = true;
+		TPRINTF("%s\n", "Double comparison failed");
 	}
 	
 	if (!test_template_unary(uint_to_double_template,
 	    uint_to_double_operator)) {
-		err = "Conversion from unsigned int to double failed";
-		TPRINTF("%s\n", err);
+		err = true;
+		TPRINTF("%s\n", "Conversion from unsigned int to double failed");
 	}
 	
 	if (!test_template_unary(double_to_uint_template,
 	    double_to_uint_operator)) {
-		err = "Conversion from double to unsigned int failed";
-		TPRINTF("%s\n", err);
+		err = true;
+		TPRINTF("%s\n", "Conversion from double to unsigned int failed");
 	}
 	
 	if (!test_template_unary(double_to_uint_template,
 	    double_to_int_operator)) {
-		err = "Conversion from double to signed int failed";
-		TPRINTF("%s\n", err);
-	}
-	
-	return err;
-}
+		err = true;
+		TPRINTF("%s\n", "Conversion from double to signed int failed");
+	}
+	
+	if (err)
+		return "Software floating point imprecision";
+	
+	return NULL;
+}
