Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/Makefile.common	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -44,6 +44,6 @@
 #   EXTRA_CLEAN        additional cleanup targets
 #
+#   MATH               set to 'y' to use the math library
 #   POSIX_COMPAT       set to 'y' to use POSIX compatibility layer
-#   NEEDS_MATH         set to 'y' to add implementation of mathematical functions
 #
 # Optionally, for a binary:
@@ -87,5 +87,5 @@
 endif
 
-ifeq ($(CONFIG_BUILD_SHARED_LIBS), y)
+ifeq ($(CONFIG_BUILD_SHARED_LIBS),y)
 	ifneq ($(SLIBRARY),)
 		LARCHIVE = $(LIBRARY).la
@@ -110,5 +110,9 @@
 LIBSOFTFLOAT_PREFIX = $(LIB_PREFIX)/softfloat
 LIBSOFTINT_PREFIX = $(LIB_PREFIX)/softint
+
 LIBMATH_PREFIX = $(LIB_PREFIX)/math
+LIBMATH_INCLUDES_FLAGS = \
+	-I$(LIBMATH_PREFIX)/include \
+	-I$(LIBMATH_PREFIX)/arch/$(UARCH)/include
 
 LIBPOSIX_PREFIX = $(LIB_PREFIX)/posix
@@ -155,5 +159,5 @@
 		STATIC_BUILD = y
 	else
-		ifeq ($(CONFIG_USE_SHARED_LIBS), y)
+		ifeq ($(CONFIG_USE_SHARED_LIBS),y)
 			STATIC_BUILD = n
 		else
@@ -172,8 +176,20 @@
 	BASE_LIBS = $(LIBC_PREFIX)/libc.a $(LIBSOFTINT_PREFIX)/libsoftint.a
 	LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link.ld
+	ifeq ($(MATH),y)
+		BASE_LIBS += $(LIBMATH_PREFIX)/libmath.a
+	endif
 else
 	BASE_LIBS = $(LIBC_PREFIX)/libc.so0 $(LIBSOFTINT_PREFIX)/libsofti.so0
 	LFLAGS = -Bdynamic
 	LINKER_SCRIPT ?= $(LIBC_PREFIX)/arch/$(UARCH)/_link-dlexe.ld
+	ifeq ($(MATH),y)
+		BASE_LIBS += $(LIBMATH_PREFIX)/libmath.so0
+	endif
+endif
+
+ifeq ($(MATH),y)
+	INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS) $(LIBMATH_INCLUDES_FLAGS)
+else
+	INCLUDES_FLAGS = $(LIBC_INCLUDES_FLAGS)
 endif
 
@@ -194,5 +210,5 @@
 	find . -name '*.lo' -follow -exec rm \{\} \;
 
-GCC_CFLAGS = $(LIBC_INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
+GCC_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
 	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
 	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
@@ -201,5 +217,5 @@
 	-pipe -ggdb -D__$(ENDIANESS)__
 
-ICC_CFLAGS = $(LIBC_INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
+ICC_CFLAGS = $(INCLUDES_FLAGS) -O$(OPTIMIZATION) -imacros $(CONFIG_HEADER) \
 	-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32$(ENDIANESS) \
 	-finput-charset=UTF-8 -ffreestanding -fno-builtin -nostdlib -nostdinc \
@@ -234,11 +250,6 @@
 # Prepare for POSIX before including platform specific stuff
 ifeq ($(POSIX_COMPAT),y)
-	CFLAGS = -I$(LIBPOSIX_PREFIX)/include/posix  -I$(LIBPOSIX_PREFIX)/include/
+	CFLAGS = -I$(LIBPOSIX_PREFIX)/include/posix -I$(LIBPOSIX_PREFIX)/include/
 	BASE_LIBS = $(LIBPOSIX_PREFIX)/libposixaslibc.a $(LIBPOSIX_PREFIX)/libc4posix.a $(LIBSOFTINT_PREFIX)/libsoftint.a
-endif
-
-# Do we need math?
-ifeq ($(NEEDS_MATH),y)
-	BASE_LIBS += $(LIBMATH_PREFIX)/libmath.a
 endif
 
Index: uspace/app/tester/Makefile
===================================================================
--- uspace/app/tester/Makefile	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/app/tester/Makefile	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -41,4 +41,5 @@
 
 BINARY = tester
+MATH = y
 
 SOURCES = \
@@ -62,4 +63,5 @@
 	fault/fault3.c \
 	float/float1.c \
+	float/float2.c \
 	float/softfloat1.c \
 	vfs/vfs1.c \
Index: uspace/app/tester/float/float2.c
===================================================================
--- uspace/app/tester/float/float2.c	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/app/tester/float/float2.c	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "../tester.h"
+
+#define OPERANDS   10
+#define PRECISION  100000000
+
+static double arguments[OPERANDS] = {
+	3.5, -2.1, 100.0, 50.0, -1024.0, 0.0, 768.3156, 1080.499999, -600.0, 1.0
+};
+
+static double results_trunc[OPERANDS] = {
+	3.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
+};
+
+static double results_sin[OPERANDS] = {
+	-0.350783227690, -0.863209366649, -0.506365641110, -0.262374853704,
+	0.158533380044, 0.0, 0.980815184715, -0.206379975025, -0.044182448332,
+	0.841470984808
+};
+
+static double results_cos[OPERANDS] = {
+	-0.936456687291, -0.504846104600, 0.862318872288, 0.964966028492,
+	0.987353618220, 1.0, -0.194939922623, 0.978471923925, -0.999023478833,
+	0.540302305868
+};
+
+const char *test_float2(void)
+{
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = trunc(arguments[i]);
+		int64_t res_int = (int64_t) (res * PRECISION);
+		int64_t corr_int = (int64_t) (results_trunc[i] * PRECISION);
+		
+		if (res_int != corr_int) {
+			TPRINTF("Double truncation failed (%" PRId64 " != %" PRId64 ")\n",
+			    res_int, corr_int);
+			return "Double truncation failed";
+		}
+	}
+	
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = sin(arguments[i]);
+		int64_t res_int = (int64_t) (res * PRECISION);
+		int64_t corr_int = (int64_t) (results_sin[i] * PRECISION);
+		
+		if (res_int != corr_int) {
+			TPRINTF("Double sine failed (%" PRId64 " != %" PRId64 ")\n",
+			    res_int, corr_int);
+			return "Double sine failed";
+		}
+	}
+	
+	for (unsigned int i = 0; i < OPERANDS; i++) {
+		double res = cos(arguments[i]);
+		int64_t res_int = (int64_t) (res * PRECISION);
+		int64_t corr_int = (int64_t) (results_cos[i] * PRECISION);
+		
+		if (res_int != corr_int) {
+			TPRINTF("Double cosine failed (%" PRId64 " != %" PRId64 ")\n",
+			    res_int, corr_int);
+			return "Double cosine failed";
+		}
+	}
+	
+	return NULL;
+}
Index: uspace/app/tester/float/float2.def
===================================================================
--- uspace/app/tester/float/float2.def	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/app/tester/float/float2.def	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,6 @@
+{
+	"float2",
+	"Floating arithmetics",
+	&test_float2,
+	true
+},
Index: uspace/app/tester/tester.c
===================================================================
--- uspace/app/tester/tester.c	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/app/tester/tester.c	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -64,4 +64,5 @@
 #include "fault/fault3.def"
 #include "float/float1.def"
+#include "float/float2.def"
 #include "float/softfloat1.def"
 #include "vfs/vfs1.def"
Index: uspace/app/tester/tester.h
===================================================================
--- uspace/app/tester/tester.h	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/app/tester/tester.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -97,4 +97,5 @@
 extern const char *test_fault3(void);
 extern const char *test_float1(void);
+extern const char *test_float2(void);
 extern const char *test_softfloat1(void);
 extern const char *test_vfs1(void);
Index: uspace/app/vdemo/Makefile
===================================================================
--- uspace/app/vdemo/Makefile	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/app/vdemo/Makefile	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -41,4 +41,5 @@
 
 BINARY = vdemo
+MATH = y
 
 SOURCES = \
Index: uspace/app/viewer/Makefile
===================================================================
--- uspace/app/viewer/Makefile	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/app/viewer/Makefile	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -41,4 +41,5 @@
 
 BINARY = viewer
+MATH = y
 
 SOURCES = \
Index: uspace/app/vlaunch/Makefile
===================================================================
--- uspace/app/vlaunch/Makefile	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/app/vlaunch/Makefile	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -41,4 +41,5 @@
 
 BINARY = vlaunch
+MATH = y
 
 SOURCES = \
Index: uspace/app/vterm/Makefile
===================================================================
--- uspace/app/vterm/Makefile	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/app/vterm/Makefile	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -43,4 +43,5 @@
 
 BINARY = vterm
+MATH = y
 
 SOURCES = \
Index: uspace/lib/c/include/math.h
===================================================================
--- uspace/lib/c/include/math.h	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/*
- * Copyright (c) 2011 Petr Koupy
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - 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.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- */
-
-/** @addtogroup libposix
- * @{
- */
-/** @file Mathematical operations.
- *
- * The implementation is provided by a separate library to allow
- * switching of the implementations.
- */
-
-#ifndef LIBC_MATH_H_
-#define LIBC_MATH_H_
-
-#ifdef __GNUC__
-	#define HUGE_VAL (__builtin_huge_val())
-#endif
-
-extern double ldexp(double, int);
-extern double frexp(double, int *);
-
-extern double fabs(double);
-extern double floor(double);
-extern double ceil(double);
-extern double modf(double, double *);
-extern double fmod(double, double);
-extern double pow(double, double);
-extern double exp(double);
-extern double expm1(double);
-extern double sqrt(double);
-extern double log(double);
-extern double log10(double);
-extern double sin(double);
-extern double sinh(double);
-extern double asin(double);
-extern double asinh(double);
-extern double cos(double);
-extern double cosh(double);
-extern double acos(double);
-extern double acosh(double);
-extern double tan(double);
-extern double tanh(double);
-extern double atan(double);
-extern double atanh(double);
-extern double atan2(double, double);
-
-double copysign(double, double);
-
-#endif
-
-/** @}
- */
Index: uspace/lib/math/Makefile
===================================================================
--- uspace/lib/math/Makefile	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/lib/math/Makefile	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -28,8 +28,22 @@
 
 USPACE_PREFIX = ../..
+ROOT_PATH = $(USPACE_PREFIX)/..
+
+CONFIG_MAKEFILE = $(ROOT_PATH)/Makefile.config
+
 LIBRARY = libmath
+SLIBRARY = libmath.so.0.0
+LSONAME = libmath.so0
+MATH = y
+
+-include $(CONFIG_MAKEFILE)
+-include arch/$(UARCH)/Makefile.inc
+
+GENERIC_SOURCES = \
+	generic/trunc.c
 
 SOURCES = \
-	src/dummy.c
+	$(GENERIC_SOURCES) \
+	$(ARCH_SOURCES)
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/math/arch/abs32le/Makefile.inc
===================================================================
--- uspace/lib/math/arch/abs32le/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/abs32le/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES =
Index: uspace/lib/math/arch/abs32le/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/abs32le/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/abs32le/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathabs32le
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_abs32le_MATH_H_
+#define LIBMATH_abs32le_MATH_H_
+
+#include <mathtypes.h>
+#include <trunc.h>
+
+static inline double trunc(double val)
+{
+	double_t arg;
+	arg.val = val;
+	
+	double_t ret;
+	ret.data = trunc_float64(arg.data);
+	
+	return ret.val;
+}
+
+static inline double sin(double val)
+{
+	// FIXME TODO
+	return 0;
+}
+
+static inline double cos(double val)
+{
+	// FIXME TODO
+	return 1;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/amd64/Makefile.inc
===================================================================
--- uspace/lib/math/arch/amd64/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/amd64/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES = \
+	arch/$(UARCH)/src/sin.S \
+	arch/$(UARCH)/src/cos.S \
+	arch/$(UARCH)/src/trunc.S
Index: uspace/lib/math/arch/amd64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/amd64/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/amd64/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathamd64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_amd64_MATH_H_
+#define LIBMATH_amd64_MATH_H_
+
+extern double sin(double);
+extern double cos(double);
+extern double trunc(double);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/amd64/include/libarch/x87.h
===================================================================
--- uspace/lib/math/arch/amd64/include/libarch/x87.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/amd64/include/libarch/x87.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathamd64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_amd64_X87_H_
+#define LIBMATH_amd64_X87_H_
+
+#define X87_CONTROL_WORD_RC_MASK           0x0c00
+#define X87_CONTROL_WORD_RC_ROUND_NEAREST  0x0000
+#define X87_CONTROL_WORD_RC_ROUND_DOWN     0x0400
+#define X87_CONTROL_WORD_RC_ROUND_UP       0x0800
+#define X87_CONTROL_WORD_RC_TRUNCATE       0x0c00
+
+#define X87_STATUS_WORD_C2_MASK  0x0400
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/amd64/src/cos.S
===================================================================
--- uspace/lib/math/arch/amd64/src/cos.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/amd64/src/cos.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,78 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+#include <libarch/x87.h>
+
+.text
+
+.global cos
+
+cos:
+	pushq %rbp
+	movq %rsp, %rbp
+	
+	# compute cosine (using red zone)
+	
+	movsd %xmm0, -8(%rbp)
+	fldl -8(%rbp)
+	
+	fcos
+	
+	# detect if source operand is out of range
+	
+	fnstsw %ax
+	andw $X87_STATUS_WORD_C2_MASK, %ax
+	jnz fix_range
+	
+		fstpl -8(%rbp)
+		movsd -8(%rbp), %xmm0
+		
+		leave
+		retq
+	
+	# argument reduction
+	
+	fix_range:
+		fldpi
+		fadd %st(0)
+		fxch %st(1)
+	
+	reduce:
+		fprem1
+		fnstsw %ax
+		andw $X87_STATUS_WORD_C2_MASK, %ax
+		jnz reduce
+	
+	fstpl %st(1)
+	fcos
+	
+	fstpl -8(%rbp)
+	movsd -8(%rbp), %xmm0
+	
+	leave
+	retq
Index: uspace/lib/math/arch/amd64/src/sin.S
===================================================================
--- uspace/lib/math/arch/amd64/src/sin.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/amd64/src/sin.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,78 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+#include <libarch/x87.h>
+
+.text
+
+.global sin
+
+sin:
+	pushq %rbp
+	movq %rsp, %rbp
+	
+	# compute sine (using red zone)
+	
+	movsd %xmm0, -8(%rbp)
+	fldl -8(%rbp)
+	
+	fsin
+	
+	# detect if source operand is out of range
+	
+	fnstsw %ax
+	andw $X87_STATUS_WORD_C2_MASK, %ax
+	jnz fix_range
+	
+		fstpl -8(%rbp)
+		movsd -8(%rbp), %xmm0
+		
+		leave
+		retq
+	
+	# argument reduction
+	
+	fix_range:
+		fldpi
+		fadd %st(0)
+		fxch %st(1)
+	
+	reduce:
+		fprem1
+		fnstsw %ax
+		andw $X87_STATUS_WORD_C2_MASK, %ax
+		jnz reduce
+	
+	fstpl %st(1)
+	fsin
+	
+	fstpl -8(%rbp)
+	movsd -8(%rbp), %xmm0
+	
+	leave
+	retq
Index: uspace/lib/math/arch/amd64/src/trunc.S
===================================================================
--- uspace/lib/math/arch/amd64/src/trunc.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/amd64/src/trunc.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,64 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+#include <libarch/x87.h>
+
+.text
+
+.global trunc
+
+trunc:
+	pushq %rbp
+	movq %rsp, %rbp
+	
+	# store x87 control word in the red zone
+	
+	fnstcw -8(%rbp)
+	movw -8(%rbp), %ax
+	
+	# set rounding control to truncate
+	# (no masking necessary for this flag)
+	
+	orw $X87_CONTROL_WORD_RC_TRUNCATE, %ax
+	movw %ax, -16(%rbp)
+	fldcw -16(%rbp)
+	
+	# truncate
+	
+	movsd %xmm0, -16(%rbp)
+	fldl -16(%rbp)
+	frndint
+	fstpl -16(%rbp)
+	movsd -16(%rbp), %xmm0
+	
+	# restore original control word
+	
+	fldcw -8(%rbp)
+	
+	leave
+	retq
Index: uspace/lib/math/arch/arm32/Makefile.inc
===================================================================
--- uspace/lib/math/arch/arm32/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/arm32/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES =
Index: uspace/lib/math/arch/arm32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/arm32/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/arm32/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmatharm32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_arm32_MATH_H_
+#define LIBMATH_arm32_MATH_H_
+
+#include <mathtypes.h>
+#include <trunc.h>
+
+static inline double trunc(double val)
+{
+	double_t arg;
+	arg.val = val;
+	
+	double_t ret;
+	ret.data = trunc_float64(arg.data);
+	
+	return ret.val;
+}
+
+static inline double sin(double val)
+{
+	// FIXME TODO
+	return 0;
+}
+
+static inline double cos(double val)
+{
+	// FIXME TODO
+	return 1;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/ia32/Makefile.inc
===================================================================
--- uspace/lib/math/arch/ia32/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/ia32/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,32 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES = \
+	arch/$(UARCH)/src/sin.S \
+	arch/$(UARCH)/src/cos.S \
+	arch/$(UARCH)/src/trunc.S
Index: uspace/lib/math/arch/ia32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/ia32/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/ia32/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathia32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_ia32_MATH_H_
+#define LIBMATH_ia32_MATH_H_
+
+extern double sin(double);
+extern double cos(double);
+extern double trunc(double);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/ia32/include/libarch/x87.h
===================================================================
--- uspace/lib/math/arch/ia32/include/libarch/x87.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/ia32/include/libarch/x87.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,1 @@
+../../../amd64/include/libarch/x87.h
Index: uspace/lib/math/arch/ia32/src/cos.S
===================================================================
--- uspace/lib/math/arch/ia32/src/cos.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/ia32/src/cos.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+#include <libarch/x87.h>
+
+.text
+
+.global cos
+
+cos:
+	# compute cosine (no stack frame)
+	
+	fldl 4(%esp)
+	fcos
+	
+	# detect if source operand is out of range
+	
+	fnstsw %ax
+	andw $X87_STATUS_WORD_C2_MASK, %ax
+	jnz fix_range
+	
+		ret
+	
+	# argument reduction
+	
+	fix_range:
+		fldpi
+		fadd %st(0)
+		fxch %st(1)
+	
+	reduce:
+		fprem1
+		fnstsw %ax
+		andw $X87_STATUS_WORD_C2_MASK, %ax
+		jnz reduce
+	
+	fstpl %st(1)
+	fcos
+	
+	ret
Index: uspace/lib/math/arch/ia32/src/sin.S
===================================================================
--- uspace/lib/math/arch/ia32/src/sin.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/ia32/src/sin.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,65 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+#include <libarch/x87.h>
+
+.text
+
+.global sin
+
+sin:
+	# compute sine (no stack frame)
+	
+	fldl 4(%esp)
+	fsin
+	
+	# detect if source operand is out of range
+	
+	fnstsw %ax
+	andw $X87_STATUS_WORD_C2_MASK, %ax
+	jnz fix_range
+	
+		ret
+	
+	# argument reduction
+	
+	fix_range:
+		fldpi
+		fadd %st(0)
+		fxch %st(1)
+	
+	reduce:
+		fprem1
+		fnstsw %ax
+		andw $X87_STATUS_WORD_C2_MASK, %ax
+		jnz reduce
+	
+	fstpl %st(1)
+	fsin
+	
+	ret
Index: uspace/lib/math/arch/ia32/src/trunc.S
===================================================================
--- uspace/lib/math/arch/ia32/src/trunc.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/ia32/src/trunc.S	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,62 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+#include <libarch/x87.h>
+
+.text
+
+.global trunc
+
+trunc:
+	pushl %ebp
+	movl %esp, %ebp
+	subl $8, %esp
+	
+	# store x87 control word
+	
+	fnstcw -4(%ebp)
+	movw -4(%ebp), %ax
+	
+	# set rounding control to truncate
+	# (no masking necessary for this flag)
+	
+	orw $X87_CONTROL_WORD_RC_TRUNCATE, %ax
+	movw %ax, -8(%ebp)
+	fldcw -8(%ebp)
+	
+	# truncate
+	
+	fldl 8(%ebp)
+	frndint
+	
+	# restore original control word
+	
+	fldcw -4(%ebp)
+	
+	leave
+	ret
Index: uspace/lib/math/arch/ia64/Makefile.inc
===================================================================
--- uspace/lib/math/arch/ia64/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/ia64/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES =
Index: uspace/lib/math/arch/ia64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/ia64/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/ia64/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathia64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_ia64_MATH_H_
+#define LIBMATH_ia64_MATH_H_
+
+#include <mathtypes.h>
+#include <trunc.h>
+
+static inline double trunc(double val)
+{
+	double_t arg;
+	arg.val = val;
+	
+	double_t ret;
+	ret.data = trunc_float64(arg.data);
+	
+	return ret.val;
+}
+
+static inline double sin(double val)
+{
+	// FIXME TODO
+	return 0;
+}
+
+static inline double cos(double val)
+{
+	// FIXME TODO
+	return 1;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/mips32/Makefile.inc
===================================================================
--- uspace/lib/math/arch/mips32/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/mips32/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES =
Index: uspace/lib/math/arch/mips32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/mips32/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/mips32/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathmips32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_mips32_MATH_H_
+#define LIBMATH_mips32_MATH_H_
+
+#include <mathtypes.h>
+#include <trunc.h>
+
+static inline double trunc(double val)
+{
+	double_t arg;
+	arg.val = val;
+	
+	double_t ret;
+	ret.data = trunc_float64(arg.data);
+	
+	return ret.val;
+}
+
+static inline double sin(double val)
+{
+	// FIXME TODO
+	return 0;
+}
+
+static inline double cos(double val)
+{
+	// FIXME TODO
+	return 1;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/mips32eb/Makefile.inc
===================================================================
--- uspace/lib/math/arch/mips32eb/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/mips32eb/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES =
Index: uspace/lib/math/arch/mips32eb/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/mips32eb/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/mips32eb/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathmips32eb
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_mips32eb_MATH_H_
+#define LIBMATH_mips32eb_MATH_H_
+
+#include <mathtypes.h>
+#include <trunc.h>
+
+static inline double trunc(double val)
+{
+	double_t arg;
+	arg.val = val;
+	
+	double_t ret;
+	ret.data = trunc_float64(arg.data);
+	
+	return ret.val;
+}
+
+static inline double sin(double val)
+{
+	// FIXME TODO
+	return 0;
+}
+
+static inline double cos(double val)
+{
+	// FIXME TODO
+	return 1;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/mips64/Makefile.inc
===================================================================
--- uspace/lib/math/arch/mips64/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/mips64/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES =
Index: uspace/lib/math/arch/mips64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/mips64/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/mips64/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathmips64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_mips64_MATH_H_
+#define LIBMATH_mips64_MATH_H_
+
+#include <mathtypes.h>
+#include <trunc.h>
+
+static inline double trunc(double val)
+{
+	double_t arg;
+	arg.val = val;
+	
+	double_t ret;
+	ret.data = trunc_float64(arg.data);
+	
+	return ret.val;
+}
+
+static inline double sin(double val)
+{
+	// FIXME TODO
+	return 0;
+}
+
+static inline double cos(double val)
+{
+	// FIXME TODO
+	return 1;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/ppc32/Makefile.inc
===================================================================
--- uspace/lib/math/arch/ppc32/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/ppc32/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES =
Index: uspace/lib/math/arch/ppc32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/ppc32/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/ppc32/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathppc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_ppc32_MATH_H_
+#define LIBMATH_ppc32_MATH_H_
+
+#include <mathtypes.h>
+#include <trunc.h>
+
+static inline double trunc(double val)
+{
+	double_t arg;
+	arg.val = val;
+	
+	double_t ret;
+	ret.data = trunc_float64(arg.data);
+	
+	return ret.val;
+}
+
+static inline double sin(double val)
+{
+	// FIXME TODO
+	return 0;
+}
+
+static inline double cos(double val)
+{
+	// FIXME TODO
+	return 1;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/sparc32/Makefile.inc
===================================================================
--- uspace/lib/math/arch/sparc32/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/sparc32/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES =
Index: uspace/lib/math/arch/sparc32/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/sparc32/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/sparc32/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathsparc32
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_sparc32_MATH_H_
+#define LIBMATH_sparc32_MATH_H_
+
+#include <mathtypes.h>
+#include <trunc.h>
+
+static inline double trunc(double val)
+{
+	double_t arg;
+	arg.val = val;
+	
+	double_t ret;
+	ret.data = trunc_float64(arg.data);
+	
+	return ret.val;
+}
+
+static inline double sin(double val)
+{
+	// FIXME TODO
+	return 0;
+}
+
+static inline double cos(double val)
+{
+	// FIXME TODO
+	return 1;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/arch/sparc64/Makefile.inc
===================================================================
--- uspace/lib/math/arch/sparc64/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/sparc64/Makefile.inc	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,29 @@
+#
+# Copyright (c) 2014 Martin Decky
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# - Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# - 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.
+# - The name of the author may not be used to endorse or promote products
+#   derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+#
+
+ARCH_SOURCES =
Index: uspace/lib/math/arch/sparc64/include/libarch/math.h
===================================================================
--- uspace/lib/math/arch/sparc64/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/arch/sparc64/include/libarch/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmathsparc64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_sparc64_MATH_H_
+#define LIBMATH_sparc64_MATH_H_
+
+#include <mathtypes.h>
+#include <trunc.h>
+
+static inline double trunc(double val)
+{
+	double_t arg;
+	arg.val = val;
+	
+	double_t ret;
+	ret.data = trunc_float64(arg.data);
+	
+	return ret.val;
+}
+
+static inline double sin(double val)
+{
+	// FIXME TODO
+	return 0;
+}
+
+static inline double cos(double val)
+{
+	// FIXME TODO
+	return 1;
+}
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/generic/trunc.c
===================================================================
--- uspace/lib/math/generic/trunc.c	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/generic/trunc.c	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#include <mathtypes.h>
+#include <trunc.h>
+
+float64 trunc_float64(float64 val)
+{
+	int32_t exp = val.parts.exp - FLOAT64_BIAS;
+	
+	if (exp < 0) {
+		/* -1 < val < 1 => result is +0 or -0 */
+		val.parts.exp = 0;
+		val.parts.fraction = 0;
+	} else if (exp >= FLOAT64_FRACTION_SIZE) {
+		if (exp == 1024) {
+			/* val is +inf, -inf or NaN => trigger an exception */
+			// FIXME TODO
+		}
+		
+		/* All bits in val are relevant for the result */
+	} else {
+		/* Truncate irrelevant fraction bits */
+		val.parts.fraction &= UINT64_C(0x000fffffffffffff) >> exp;
+	}
+	
+	return val;
+}
+
+/** @}
+ */
Index: uspace/lib/math/include/math.h
===================================================================
--- uspace/lib/math/include/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/include/math.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011 Petr Koupy
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file Mathematical operations.
+ */
+
+#ifndef LIBMATH_MATH_H_
+#define LIBMATH_MATH_H_
+
+#include <libarch/math.h>
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/mathtypes.h
===================================================================
--- uspace/lib/math/include/mathtypes.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/include/mathtypes.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2005 Josef Cejka
+ * Copyright (c) 2011 Petr Koupy
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file Floating point types and constants.
+ */
+
+#ifndef LIBMATH_MATHTYPES_H_
+#define LIBMATH_MATHTYPES_H_
+
+#include <byteorder.h>
+#include <stdint.h>
+
+/*
+ * For recognizing NaNs or infinity use specialized comparison
+ * functions, comparing with these constants is not sufficient.
+ */
+
+#define FLOAT32_NAN     UINT32_C(0x7fc00001)
+#define FLOAT32_SIGNAN  UINT32_C(0x7f800001)
+#define FLOAT32_INF     UINT32_C(0x7f800000)
+
+#define FLOAT64_NAN     UINT64_C(0x7ff8000000000001)
+#define FLOAT64_SIGNAN  UINT64_C(0x7ff0000000000001)
+#define FLOAT64_INF     UINT64_C(0x7ff0000000000000)
+
+#define FLOAT96_NAN_HI     UINT64_C(0x7fff80000000)
+#define FLOAT96_NAN_LO     UINT32_C(0x00010000)
+#define FLOAT96_SIGNAN_HI  UINT64_C(0x7fff00000000)
+#define FLOAT96_SIGNAN_LO  UINT32_C(0x00010000)
+
+#define FLOAT128_NAN_HI     UINT64_C(0x7fff800000000000)
+#define FLOAT128_NAN_LO     UINT64_C(0x0000000000000001)
+#define FLOAT128_SIGNAN_HI  UINT64_C(0x7fff000000000000)
+#define FLOAT128_SIGNAN_LO  UINT64_C(0x0000000000000001)
+#define FLOAT128_INF_HI     UINT64_C(0x7fff000000000000)
+#define FLOAT128_INF_LO     UINT64_C(0x0000000000000000)
+
+#define FLOAT32_FRACTION_SIZE   23
+#define FLOAT64_FRACTION_SIZE   52
+#define FLOAT96_FRACTION_SIZE   64
+#define FLOAT128_FRACTION_SIZE  112
+#define FLOAT128_FRAC_HI_SIZE   48
+#define FLOAT128_FRAC_LO_SIZE   64
+
+#define FLOAT32_HIDDEN_BIT_MASK      UINT32_C(0x800000)
+#define FLOAT64_HIDDEN_BIT_MASK      UINT64_C(0x10000000000000)
+#define FLOAT128_HIDDEN_BIT_MASK_HI  UINT64_C(0x1000000000000)
+#define FLOAT128_HIDDEN_BIT_MASK_LO  UINT64_C(0x0000000000000000)
+
+#define FLOAT32_MAX_EXPONENT   0xff
+#define FLOAT64_MAX_EXPONENT   0x7ff
+#define FLOAT96_MAX_EXPONENT   0x7fff
+#define FLOAT128_MAX_EXPONENT  0x7fff
+
+#define FLOAT32_BIAS   0x7f
+#define FLOAT64_BIAS   0x3ff
+#define FLOAT96_BIAS   0x3fff
+#define FLOAT128_BIAS  0x3fff
+
+#if defined(__BE__)
+
+typedef union {
+	uint32_t bin;
+	
+	struct {
+		uint32_t sign : 1;
+		uint32_t exp : 8;
+		uint32_t fraction : 23;
+	} parts __attribute__((packed));
+} float32;
+
+typedef union {
+	uint64_t bin;
+	
+	struct {
+		uint64_t sign : 1;
+		uint64_t exp : 11;
+		uint64_t fraction : 52;
+	} parts __attribute__((packed));
+} float64;
+
+typedef union {
+	struct {
+		uint64_t hi;
+		uint32_t lo;
+	} bin __attribute__((packed));
+	
+	struct {
+		uint64_t padding : 16;
+		uint64_t sign : 1;
+		uint64_t exp : 15;
+		uint64_t fraction : 64;
+	} parts __attribute__((packed));
+} float96;
+
+typedef union {
+	struct {
+		uint64_t hi;
+		uint64_t lo;
+	} bin __attribute__((packed));
+	
+	struct {
+		uint64_t sign : 1;
+		uint64_t exp : 15;
+		uint64_t frac_hi : 48;
+		uint64_t frac_lo : 64;
+	} parts __attribute__((packed));
+} float128;
+
+#elif defined(__LE__)
+
+typedef union {
+	uint32_t bin;
+	
+	struct {
+		uint32_t fraction : 23;
+		uint32_t exp : 8;
+		uint32_t sign : 1;
+	} parts __attribute__((packed));
+} float32;
+
+typedef union {
+	uint64_t bin;
+	
+	struct {
+		uint64_t fraction : 52;
+		uint64_t exp : 11;
+		uint64_t sign : 1;
+	} parts __attribute__((packed));
+} float64;
+
+typedef union {
+	struct {
+		uint32_t lo;
+		uint64_t hi;
+	} bin __attribute__((packed));
+	
+	struct {
+		uint64_t fraction : 64;
+		uint64_t exp : 15;
+		uint64_t sign : 1;
+		uint64_t padding : 16;
+	} parts __attribute__((packed));
+} float96;
+
+typedef union {
+	struct {
+		uint64_t lo;
+		uint64_t hi;
+	} bin __attribute__((packed));
+	
+	struct {
+		uint64_t frac_lo : 64;
+		uint64_t frac_hi : 48;
+		uint64_t exp : 15;
+		uint64_t sign : 1;
+	} parts __attribute__((packed));
+} float128;
+
+#else
+	#error Unknown endianess
+#endif
+
+typedef union {
+	float val;
+	
+#if defined(FLOAT_SIZE_32)
+	float32 data;
+#elif defined(FLOAT_SIZE_64)
+	float64 data;
+#elif defined(FLOAT_SIZE_96)
+	float96 data;
+#elif defined(FLOAT_SIZE_128)
+	float128 data;
+#else
+	#error Unsupported float size
+#endif
+} float_t;
+
+typedef union {
+	double val;
+	
+#if defined(DOUBLE_SIZE_32)
+	float32 data;
+#elif defined(DOUBLE_SIZE_64)
+	float64 data;
+#elif defined(DOUBLE_SIZE_96)
+	float96 data;
+#elif defined(DOUBLE_SIZE_128)
+	float128 data;
+#else
+	#error Unsupported double size
+#endif
+} double_t;
+
+typedef union {
+	long double val;
+	
+#if defined(LONG_DOUBLE_SIZE_32)
+	float32 data;
+#elif defined(LONG_DOUBLE_SIZE_64)
+	float64 data;
+#elif defined(LONG_DOUBLE_SIZE_96)
+	float96 data;
+#elif defined(LONG_DOUBLE_SIZE_128)
+	float128 data;
+#else
+	#error Unsupported long double size
+#endif
+} long_double_t;
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/include/trunc.h
===================================================================
--- uspace/lib/math/include/trunc.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
+++ uspace/lib/math/include/trunc.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2014 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - 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.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef LIBMATH_TRUNC_H_
+#define LIBMATH_TRUNC_H_
+
+#include <mathtypes.h>
+
+extern float64 trunc_float64(float64);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/src/dummy.c
===================================================================
--- uspace/lib/math/src/dummy.c	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ 	(revision )
@@ -1,214 +1,0 @@
-/*
- * Copyright (c) 2011 Petr Koupy
- * Copyright (c) 2013 Vojtech Horky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - 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.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- */
-
-/** @addtogroup libmath
- * @{
- */
-/** @file Mathematical operations (dummy implementation).
- */
-#include <math.h>
-#include <stdio.h>
-
-#define WARN_NOT_IMPLEMENTED() \
-	do { \
-		static int __not_implemented_counter = 0; \
-		if (__not_implemented_counter == 0) { \
-			fprintf(stderr, "Warning: using dummy implementation of %s().\n", \
-				__func__); \
-		} \
-		__not_implemented_counter++; \
-	} while (0)
-
-double ldexp(double x, int exp)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double frexp(double num, int *exp)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double cos(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double cosh(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double acos(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double acosh(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double pow(double x, double y)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double floor(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double ceil(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double fabs(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double modf(double x, double *iptr)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double fmod(double x, double y)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double log(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double log10(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-
-double atan2(double y, double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double sin(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double sinh(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double asin(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double asinh(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double tan(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double tanh(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double atan(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double atanh(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-
-double exp(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double expm1(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double sqrt(double x)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-double copysign(double x, double y)
-{
-	WARN_NOT_IMPLEMENTED();
-	return 0.0;
-}
-
-
-/** @}
- */
Index: uspace/lib/softfloat/Makefile
===================================================================
--- uspace/lib/softfloat/Makefile	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/lib/softfloat/Makefile	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -30,4 +30,5 @@
 USPACE_PREFIX = ../..
 LIBRARY = libsoftfloat
+MATH = y
 
 SOURCES = \
@@ -39,6 +40,5 @@
 	mul.c \
 	comparison.c \
-	conversion.c \
-	other.c
+	conversion.c
 
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/softfloat/other.c
===================================================================
--- uspace/lib/softfloat/other.c	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ 	(revision )
@@ -1,37 +1,0 @@
-/*
- * Copyright (c) 2005 Josef Cejka
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - 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.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- */
-
-/** @addtogroup softfloat
- * @{
- */
-/** @file Other functions (power, complex).
- */
-
-
-/** @}
- */
Index: uspace/lib/softfloat/other.h
===================================================================
--- uspace/lib/softfloat/other.h	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ 	(revision )
@@ -1,41 +1,0 @@
-/*
- * Copyright (c) 2005 Josef Cejka
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - 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.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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.
- */
-
-/** @addtogroup softfloat
- * @{
- */
-/** @file Other functions (power, complex).
- */
-
-#ifndef __OTHER_H__
-#define __OTHER_H__
-
-#endif
-
-/** @}
- */
Index: uspace/lib/softfloat/sftypes.h
===================================================================
--- uspace/lib/softfloat/sftypes.h	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/lib/softfloat/sftypes.h	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -34,209 +34,8 @@
  */
 
-#ifndef __SFTYPES_H__
-#define __SFTYPES_H__
-
-#include <byteorder.h>
-#include <stdint.h>
-
-/*
- * For recognizing NaNs or infinity use specialized comparison
- * functions, comparing with these constants is not sufficient.
- */
-
-#define FLOAT32_NAN     UINT32_C(0x7FC00001)
-#define FLOAT32_SIGNAN  UINT32_C(0x7F800001)
-#define FLOAT32_INF     UINT32_C(0x7F800000)
-
-#define FLOAT64_NAN     UINT64_C(0x7FF8000000000001)
-#define FLOAT64_SIGNAN  UINT64_C(0x7FF0000000000001)
-#define FLOAT64_INF     UINT64_C(0x7FF0000000000000)
-
-#define FLOAT96_NAN_HI     UINT64_C(0x7FFF80000000)
-#define FLOAT96_NAN_LO     UINT32_C(0x00010000)
-#define FLOAT96_SIGNAN_HI  UINT64_C(0x7FFF00000000)
-#define FLOAT96_SIGNAN_LO  UINT32_C(0x00010000)
-
-#define FLOAT128_NAN_HI     UINT64_C(0x7FFF800000000000)
-#define FLOAT128_NAN_LO     UINT64_C(0x0000000000000001)
-#define FLOAT128_SIGNAN_HI  UINT64_C(0x7FFF000000000000)
-#define FLOAT128_SIGNAN_LO  UINT64_C(0x0000000000000001)
-#define FLOAT128_INF_HI     UINT64_C(0x7FFF000000000000)
-#define FLOAT128_INF_LO     UINT64_C(0x0000000000000000)
-
-#define FLOAT32_FRACTION_SIZE   23
-#define FLOAT64_FRACTION_SIZE   52
-#define FLOAT96_FRACTION_SIZE   64
-#define FLOAT128_FRACTION_SIZE  112
-#define FLOAT128_FRAC_HI_SIZE   48
-#define FLOAT128_FRAC_LO_SIZE   64
-
-#define FLOAT32_HIDDEN_BIT_MASK      UINT32_C(0x800000)
-#define FLOAT64_HIDDEN_BIT_MASK      UINT64_C(0x10000000000000)
-#define FLOAT128_HIDDEN_BIT_MASK_HI  UINT64_C(0x1000000000000)
-#define FLOAT128_HIDDEN_BIT_MASK_LO  UINT64_C(0x0000000000000000)
-
-#define FLOAT32_MAX_EXPONENT   0xFF
-#define FLOAT64_MAX_EXPONENT   0x7FF
-#define FLOAT96_MAX_EXPONENT   0x7FFF
-#define FLOAT128_MAX_EXPONENT  0x7FFF
-
-#define FLOAT32_BIAS   0x7F
-#define FLOAT64_BIAS   0x3FF
-#define FLOAT96_BIAS   0x3FFF
-#define FLOAT128_BIAS  0x3FFF
-
-#if defined(__BE__)
-
-typedef union {
-	uint32_t bin;
-	
-	struct {
-		uint32_t sign : 1;
-		uint32_t exp : 8;
-		uint32_t fraction : 23;
-	} parts __attribute__((packed));
-} float32;
-
-typedef union {
-	uint64_t bin;
-	
-	struct {
-		uint64_t sign : 1;
-		uint64_t exp : 11;
-		uint64_t fraction : 52;
-	} parts __attribute__((packed));
-} float64;
-
-typedef union {
-	struct {
-		uint64_t hi;
-		uint32_t lo;
-	} bin __attribute__((packed));
-	
-	struct {
-		uint64_t padding : 16;
-		uint64_t sign : 1;
-		uint64_t exp : 15;
-		uint64_t fraction : 64;
-	} parts __attribute__((packed));
-} float96;
-
-typedef union {
-	struct {
-		uint64_t hi;
-		uint64_t lo;
-	} bin __attribute__((packed));
-	
-	struct {
-		uint64_t sign : 1;
-		uint64_t exp : 15;
-		uint64_t frac_hi : 48;
-		uint64_t frac_lo : 64;
-	} parts __attribute__((packed));
-} float128;
-
-#elif defined(__LE__)
-
-typedef union {
-	uint32_t bin;
-	
-	struct {
-		uint32_t fraction : 23;
-		uint32_t exp : 8;
-		uint32_t sign : 1;
-	} parts __attribute__((packed));
-} float32;
-
-typedef union {
-	uint64_t bin;
-	
-	struct {
-		uint64_t fraction : 52;
-		uint64_t exp : 11;
-		uint64_t sign : 1;
-	} parts __attribute__((packed));
-} float64;
-
-typedef union {
-	struct {
-		uint32_t lo;
-		uint64_t hi;
-	} bin __attribute__((packed));
-	
-	struct {
-		uint64_t fraction : 64;
-		uint64_t exp : 15;
-		uint64_t sign : 1;
-		uint64_t padding : 16;
-	} parts __attribute__((packed));
-} float96;
-
-typedef union {
-	struct {
-		uint64_t lo;
-		uint64_t hi;
-	} bin __attribute__((packed));
-	
-	struct {
-		uint64_t frac_lo : 64;
-		uint64_t frac_hi : 48;
-		uint64_t exp : 15;
-		uint64_t sign : 1;
-	} parts __attribute__((packed));
-} float128;
-
-#else
-	#error Unknown endianess
-#endif
-
-typedef union {
-	float val;
-	
-#if defined(FLOAT_SIZE_32)
-	float32 data;
-#elif defined(FLOAT_SIZE_64)
-	float64 data;
-#elif defined(FLOAT_SIZE_96)
-	float96 data;
-#elif defined(FLOAT_SIZE_128)
-	float128 data;
-#else
-	#error Unsupported float size
-#endif
-} float_t;
-
-typedef union {
-	double val;
-	
-#if defined(DOUBLE_SIZE_32)
-	float32 data;
-#elif defined(DOUBLE_SIZE_64)
-	float64 data;
-#elif defined(DOUBLE_SIZE_96)
-	float96 data;
-#elif defined(DOUBLE_SIZE_128)
-	float128 data;
-#else
-	#error Unsupported double size
-#endif
-} double_t;
-
-typedef union {
-	long double val;
-	
-#if defined(LONG_DOUBLE_SIZE_32)
-	float32 data;
-#elif defined(LONG_DOUBLE_SIZE_64)
-	float64 data;
-#elif defined(LONG_DOUBLE_SIZE_96)
-	float96 data;
-#elif defined(LONG_DOUBLE_SIZE_128)
-	float128 data;
-#else
-	#error Unsupported long double size
-#endif
-} long_double_t;
-
+#ifndef SOFTFLOAT_SFTYPES_H__
+#define SOFTFLOAT_SFTYPES_H__
+
+#include <mathtypes.h>
 
 #if defined(INT_SIZE_8)
Index: uspace/lib/softfloat/softfloat.c
===================================================================
--- uspace/lib/softfloat/softfloat.c	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/lib/softfloat/softfloat.c	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -44,5 +44,4 @@
 #include "conversion.h"
 #include "comparison.h"
-#include "other.h"
 
 /* Arithmetic functions */
Index: uspace/lib/softrend/Makefile
===================================================================
--- uspace/lib/softrend/Makefile	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/lib/softrend/Makefile	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -31,4 +31,5 @@
 SLIBRARY = libsoftrend.so.0.0
 LSONAME = libsoftrend.so0
+MATH = y
 
 SOURCES = \
Index: uspace/srv/hid/compositor/Makefile
===================================================================
--- uspace/srv/hid/compositor/Makefile	(revision 75baf6e5b3db6c93c63bd2f29197c44dc8d509f2)
+++ uspace/srv/hid/compositor/Makefile	(revision d9be488aaf4d20f1c61c594ac3595cdf66202e01)
@@ -28,4 +28,5 @@
 
 USPACE_PREFIX = ../../..
+
 LIBS = \
 	$(LIBDRAW_PREFIX)/libdraw.a \
@@ -40,4 +41,5 @@
 
 BINARY = compositor
+MATH = y
 
 SOURCES = \
