Index: uspace/Makefile
===================================================================
--- uspace/Makefile	(revision f5ceb180ed8e75b28e5e58b6254e858c7cf265d3)
+++ uspace/Makefile	(revision 8620b2f4bee911da50b9a6a31d291747857234b0)
@@ -240,4 +240,5 @@
 	lib/softrend \
 	lib/draw \
+	lib/math \
 	lib/net \
 	lib/nic \
Index: uspace/Makefile.common
===================================================================
--- uspace/Makefile.common	(revision f5ceb180ed8e75b28e5e58b6254e858c7cf265d3)
+++ uspace/Makefile.common	(revision 8620b2f4bee911da50b9a6a31d291747857234b0)
@@ -45,4 +45,5 @@
 #
 #   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:
@@ -109,4 +110,5 @@
 LIBSOFTFLOAT_PREFIX = $(LIB_PREFIX)/softfloat
 LIBSOFTINT_PREFIX = $(LIB_PREFIX)/softint
+LIBMATH_PREFIX = $(LIB_PREFIX)/math
 
 LIBPOSIX_PREFIX = $(LIB_PREFIX)/posix
@@ -233,4 +235,9 @@
 endif
 
+# Do we need math?
+ifeq ($(NEEDS_MATH),y)
+	BASE_LIBS += $(LIBMATH_PREFIX)/libmath.a
+endif
+
 ## Setup platform configuration
 #
Index: uspace/lib/c/include/math.h
===================================================================
--- uspace/lib/c/include/math.h	(revision 8620b2f4bee911da50b9a6a31d291747857234b0)
+++ uspace/lib/c/include/math.h	(revision 8620b2f4bee911da50b9a6a31d291747857234b0)
@@ -0,0 +1,63 @@
+/*
+ * 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 modf(double, double *);
+extern double fmod(double, double);
+extern double pow(double, double);
+extern double exp(double);
+extern double sqrt(double);
+extern double log(double);
+extern double sin(double);
+extern double cos(double);
+extern double atan2(double, double);
+
+#endif
+
+/** @}
+ */
Index: uspace/lib/math/Makefile
===================================================================
--- uspace/lib/math/Makefile	(revision 8620b2f4bee911da50b9a6a31d291747857234b0)
+++ uspace/lib/math/Makefile	(revision 8620b2f4bee911da50b9a6a31d291747857234b0)
@@ -0,0 +1,35 @@
+#
+# 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.
+#
+
+USPACE_PREFIX = ../..
+LIBRARY = libmath
+
+SOURCES = \
+	src/dummy.c
+
+include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/math/src/dummy.c
===================================================================
--- uspace/lib/math/src/dummy.c	(revision 8620b2f4bee911da50b9a6a31d291747857234b0)
+++ uspace/lib/math/src/dummy.c	(revision 8620b2f4bee911da50b9a6a31d291747857234b0)
@@ -0,0 +1,127 @@
+/*
+ * 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 pow(double x, double y)
+{
+	WARN_NOT_IMPLEMENTED();
+	return 0.0;
+}
+
+double floor(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 atan2(double y, double x)
+{
+	WARN_NOT_IMPLEMENTED();
+	return 0.0;
+}
+
+double sin(double x)
+{
+	WARN_NOT_IMPLEMENTED();
+	return 0.0;
+}
+
+double exp(double x)
+{
+	WARN_NOT_IMPLEMENTED();
+	return 0.0;
+}
+
+double sqrt(double x)
+{
+	WARN_NOT_IMPLEMENTED();
+	return 0.0;
+}
+
+/** @}
+ */
Index: uspace/lib/posix/Makefile
===================================================================
--- uspace/lib/posix/Makefile	(revision f5ceb180ed8e75b28e5e58b6254e858c7cf265d3)
+++ uspace/lib/posix/Makefile	(revision 8620b2f4bee911da50b9a6a31d291747857234b0)
@@ -60,5 +60,4 @@
 	source/getopt.c \
 	source/locale.c \
-	source/math.c \
 	source/pthread/condvar.c \
 	source/pthread/keys.c \
Index: uspace/lib/posix/include/posix/math.h
===================================================================
--- uspace/lib/posix/include/posix/math.h	(revision f5ceb180ed8e75b28e5e58b6254e858c7cf265d3)
+++ uspace/lib/posix/include/posix/math.h	(revision 8620b2f4bee911da50b9a6a31d291747857234b0)
@@ -36,27 +36,5 @@
 #define POSIX_MATH_H_
 
-#ifndef __POSIX_DEF__
-#define __POSIX_DEF__(x) x
-#endif
-
-#ifdef __GNUC__
-	#define HUGE_VAL (__builtin_huge_val())
-#endif
-
-/* Normalization Functions */
-extern double __POSIX_DEF__(ldexp)(double x, int exp);
-extern double __POSIX_DEF__(frexp)(double num, int *exp);
-
-double __POSIX_DEF__(fabs)(double x);
-double __POSIX_DEF__(floor)(double x);
-double __POSIX_DEF__(modf)(double x, double *iptr);
-double __POSIX_DEF__(fmod)(double x, double y);
-double __POSIX_DEF__(pow)(double x, double y);
-double __POSIX_DEF__(exp)(double x);
-double __POSIX_DEF__(sqrt)(double x);
-double __POSIX_DEF__(log)(double x);
-double __POSIX_DEF__(sin)(double x);
-double __POSIX_DEF__(cos)(double x);
-double __POSIX_DEF__(atan2)(double y, double x);
+#include "libc/math.h"
 
 #endif /* POSIX_MATH_H_ */
Index: pace/lib/posix/source/math.c
===================================================================
--- uspace/lib/posix/source/math.c	(revision f5ceb180ed8e75b28e5e58b6254e858c7cf265d3)
+++ 	(revision )
@@ -1,204 +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.
- */
-
-#define LIBPOSIX_INTERNAL
-#define __POSIX_DEF__(x) posix_##x
-
-#include "internal/common.h"
-#include "posix/math.h"
-
-/**
- * 
- * @param x
- * @param exp
- * @return
- */
-double posix_ldexp(double x, int exp)
-{
-	// TODO: low priority, just a compile-time dependency of binutils
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param num
- * @param exp
- * @return
- */
-double posix_frexp(double num, int *exp)
-{
-	// TODO: low priority, just a compile-time dependency of binutils
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @return
- */
-double posix_cos(double x)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @param y
- * @return
- */
-double posix_pow(double x, double y)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @return
- */
-double posix_floor(double x)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @return
- */
-double posix_fabs(double x)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @param iptr
- * @return
- */
-double posix_modf(double x, double *iptr)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @param y
- * @return
- */
-double posix_fmod(double x, double y)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @return
- */
-double posix_log(double x)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @param y
- * @return
- */
-double posix_atan2(double y, double x)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @return
- */
-double posix_sin(double x)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @return
- */
-double posix_exp(double x)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/**
- * 
- * @param x
- * @return
- */
-double posix_sqrt(double x)
-{
-	// TODO: Python dependency
-	not_implemented();
-	return 0.0;
-}
-
-/** @}
- */
