[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH] Libc: Erstes Stueck richtige libm



From: patrick <patrick@xxxxxxxxxxxxxxxx>

+ Libc: Erstes Stueck richtige libm

Signed-off-by: Patrick Kaufmann <patrick@xxxxxxxxxx>
---
 src/modules/include/math.h            |   74 ++++++++++++----
 src/modules/lib/stdlibc/math.c        |   45 ----------
 src/modules/lib/stdlibc/math/fabs.c   |   64 ++++++++++++++
 src/modules/lib/stdlibc/math/fcos.c   |   85 ++++++++++++++++++
 src/modules/lib/stdlibc/math/fexp.c   |   58 ++++++++++++
 src/modules/lib/stdlibc/math/fldexp.c |  112 ++++++++++++++++++++++++
 src/modules/lib/stdlibc/math/flog.c   |  154 +++++++++++++++++++++++++++++++++
 src/modules/lib/stdlibc/math/fsin.c   |   83 ++++++++++++++++++
 src/modules/lib/stdlibc/math/fsqrt.c  |   64 ++++++++++++++
 src/modules/lib/stdlibc/math/ftan.c   |  143 ++++++++++++++++++++++++++++++
 10 files changed, 820 insertions(+), 62 deletions(-)
 delete mode 100644 src/modules/lib/stdlibc/math.c
 create mode 100644 src/modules/lib/stdlibc/math/fabs.c
 create mode 100644 src/modules/lib/stdlibc/math/fcos.c
 create mode 100644 src/modules/lib/stdlibc/math/fexp.c
 create mode 100644 src/modules/lib/stdlibc/math/fldexp.c
 create mode 100644 src/modules/lib/stdlibc/math/flog.c
 create mode 100644 src/modules/lib/stdlibc/math/fsin.c
 create mode 100644 src/modules/lib/stdlibc/math/fsqrt.c
 create mode 100644 src/modules/lib/stdlibc/math/ftan.c

diff --git a/src/modules/include/math.h b/src/modules/include/math.h
index 8be2d9c..a5d39b4 100644
--- a/src/modules/include/math.h
+++ b/src/modules/include/math.h
@@ -1,8 +1,8 @@
-/*  
- * Copyright (c) 2007 The tyndur Project. All rights reserved.
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
  *
  * This code is derived from software contributed to the tyndur Project
- * by Antoine Kaufmann.
+ * by Patrick Kaufmann.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -13,26 +13,66 @@
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
  *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * ``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 COPYRIGHT HOLDERS OR 
- * CONTRIBUTORS 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 
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS 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.
- */  
+ */
 
 #ifndef _MATH_H_
 #define _MATH_H_
-#include <lost/config.h>
 
-// Betrag einer reelen Zahl errechen
-#ifndef CONFIG_LIBC_NO_STUBS
-double fabs(double x);
-#endif
+# define NAN    (__builtin_nanf (""))
+
+double      tan(double);
+float       tanf(float);
+long double tanl(long double);
+double      sqrt(double);
+float       sqrtf(float);
+long double sqrtl(long double);
+double      sin(double);
+float       sinf(float);
+long double sinl(long double);
+double      log2(double);
+float       log2f(float);
+long double log2l(long double);
+double      log10(double);
+float       log10f(float);
+long double log10l(long double);
+double      log(double);
+float       logf(float);
+long double logl(long double);
+double      ldexp(double, int);
+float       ldexpf(float, int);
+long double ldexpl(long double, int);
+double      fabs(double);
+float       fabsf(float);
+long double fabsl(long double);
+double      exp(double);
+float       expf(float);
+long double expl(long double);
+double      cos(double);
+float       cosf(float);
+long double cosl(long double);
+double      atan(double);
+float       atanf(float);
+long double atanl(long double);
+double      atan2(double, double);
+float       atan2f(float, float);
+long double atan2l(long double, long double);
+double      asin(double);
+float       asinf(float);
+long double asinl(long double);
+double      acos(double);
+float       acosf(float);
+long double acosl(long double);
 
 #endif
+
diff --git a/src/modules/lib/stdlibc/math.c b/src/modules/lib/stdlibc/math.c
deleted file mode 100644
index 76d437f..0000000
--- a/src/modules/lib/stdlibc/math.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2007 The tyndur Project. All rights reserved.
- *
- * This code is derived from software contributed to the tyndur Project
- * by Antoine Kaufmann.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``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 COPYRIGHT HOLDERS OR
- * CONTRIBUTORS 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 <math.h>
-#include <lost/config.h>
-
-// FIXME: Nur bis der Float-Kram vom Kernel unterstuetzt wird
-#ifndef CONFIG_LIBC_NO_STUBS
-
-/**
- * Betrag einer reellen Zahl errechnen
- */
-double fabs(double x)
-{
-    return ((x < 0) ? -x : x);
-}
-
-#endif
-
diff --git a/src/modules/lib/stdlibc/math/fabs.c b/src/modules/lib/stdlibc/math/fabs.c
new file mode 100644
index 0000000..06a9098
--- /dev/null
+++ b/src/modules/lib/stdlibc/math/fabs.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Patrick Kaufmann.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``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 COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS 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 "math.h"
+#include <errno.h>
+
+double fabs(double x)
+{
+    double res;
+    if (x < 0.0) {
+        return -x;
+    } 
+    else {
+    return res;
+    }
+}
+
+float fabsf(float x)
+{
+    float res;
+    if (x < 0.0) {
+        return -x;
+    } 
+    else {
+    return res;
+    }
+}
+
+long double fabsl(long double x)
+{
+    long double res;
+    if (x < 0.0) {
+        return -x;
+    } 
+    else {
+    return res;
+    }
+}
+
diff --git a/src/modules/lib/stdlibc/math/fcos.c b/src/modules/lib/stdlibc/math/fcos.c
new file mode 100644
index 0000000..06d2d7d
--- /dev/null
+++ b/src/modules/lib/stdlibc/math/fcos.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Patrick Kaufmann.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``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 COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS 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 "math.h"
+#include <errno.h>
+
+#define pio2 1.570796326794896619
+
+double cos(double x)
+{
+    double res;
+    asm("fcos;" : "=t" (res) : "0" (x));
+    return res;
+}
+
+float cosf(float x)
+{
+    float res;
+    asm("fcos" : "=t" (res) : "0" (x));
+    return res;
+}
+
+long double cosl(long double x)
+{
+    long double res;
+    asm("fcos" : "=t" (res) : "0" (x));
+    return res;
+}
+
+double acos(double x) {
+    double res;
+    if (x <= -1 || x >= 1) {
+        errno = EDOM;
+        return NAN;
+    }
+    res = pio2 - asin(x);
+    return res;
+}
+
+float acosf(float x) {
+    float res;
+    if (x <= -1 || x >= 1) {
+        errno = EDOM;
+        return NAN;
+    }
+    res = pio2 - asin(x);
+    return res;
+}
+
+long double acosl(long double x) {
+    long double res;
+    if (x <= -1 || x >= 1) {
+        errno = EDOM;
+        return NAN;
+    }
+    res = pio2 - asin(x);
+    return res;
+}
+
+
diff --git a/src/modules/lib/stdlibc/math/fexp.c b/src/modules/lib/stdlibc/math/fexp.c
new file mode 100644
index 0000000..fbc48f5
--- /dev/null
+++ b/src/modules/lib/stdlibc/math/fexp.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Patrick Kaufmann.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``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 COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS 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 "math.h"
+#include <errno.h>
+
+double exp(double x)
+{
+    double one = 1;
+    double res;
+    asm("fyl2x;"
+        "f2xm1": "=t" (res) : "0" (x), "u" (one));
+    return res;
+}
+
+float expf(float x)
+{
+    float one = 1;
+    float res;
+    asm("fyl2x;"
+        "f2xm1": "=t" (res) : "0" (x), "u" (one));
+    return res;
+}
+
+long double expl(long double x)
+{
+    long double one = 1;
+    long double res;
+    asm("fyl2x;"
+        "f2xm1" : "=t" (res) : "0" (x), "u" (one));
+    return res;
+}
+
diff --git a/src/modules/lib/stdlibc/math/fldexp.c b/src/modules/lib/stdlibc/math/fldexp.c
new file mode 100644
index 0000000..83dd8da
--- /dev/null
+++ b/src/modules/lib/stdlibc/math/fldexp.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Patrick Kaufmann.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``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 COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS 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 "math.h"
+#include <errno.h>
+
+double ldexp(double x, int exp)
+{
+    double res = x;
+    int exponent;
+    int i;
+    if (!exp) {
+        if (!x) {
+            errno = EDOM;
+            return NAN;
+        }
+        return 1;
+    }
+    exponent = exp;
+    if (exp < 0) {
+        exponent = -exp;
+    }
+    for (i = 1; i < exponent; i++) {
+        res *= x;
+    }
+
+    if (exp < 0) {
+        return 1 / res;
+    }
+    
+    return res;
+}
+
+float ldexpf(float x, int exp)
+{
+    float res = x;
+    int exponent;
+    int i;
+    if (!exp) {
+        if (!x) {
+            errno = EDOM;
+            return NAN;
+        }
+        return 1;
+    }
+    exponent = exp;
+    if (exp < 0) {
+        exponent = -exp;
+    }
+    for (i = 1; i < exponent; i++) {
+        res *= x;
+    }
+
+    if (exp < 0) {
+        return 1 / res;
+    }
+    
+    return res;
+}
+
+long double ldexpl(long double x, int exp)
+{
+    long double res = x;
+    int exponent;
+    int i;
+    if (!exp) {
+        if (!x) {
+            errno = EDOM;
+            return NAN;
+        }
+        return 1;
+    }
+    exponent = exp;
+    if (exp < 0) {
+        exponent = -exp;
+    }
+    for (i = 1; i < exponent; i++) {
+        res *= x;
+    }
+
+    if (exp < 0) {
+        return 1 / res;
+    }
+    
+    return res;
+}
+
diff --git a/src/modules/lib/stdlibc/math/flog.c b/src/modules/lib/stdlibc/math/flog.c
new file mode 100644
index 0000000..ca5c457
--- /dev/null
+++ b/src/modules/lib/stdlibc/math/flog.c
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Patrick Kaufmann.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``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 COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS 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 "math.h"
+#include <errno.h>
+
+double log2(double x)
+{
+    double one = 1;
+    double res;
+    if (x <= 0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fyl2x" : "=t" (res) : "0" (x), "u" (one));
+}
+
+float log2f(float x)
+{
+    double one = 1;
+    double res;
+    if (x <= 0.0) {
+        errno = EDOM;
+        return NAN;
+    } 
+    asm("fyl2x" : "=t" (res) : "0" (x), "u" (one));
+}
+
+
+long double log2l(long double x)
+{
+    long double one = 1;
+    long double res;
+    if (x <= 0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fyl2x" : "=t" (res) : "0" (x), "u" (one));
+}
+
+double log(double x)
+{
+    double one = 1;
+    double res;
+    if (x <= 0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fyl2x;"
+        "fldl2e;"
+        "fdivp" : "=t" (res) : "0" (x), "u" (one));
+    return res;
+}
+
+float logf(float x)
+{
+    float one = 1;
+    float res;
+    if (x <= 0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fyl2x;"
+        "fldl2e;"
+        "fdivp" : "=t" (res) : "0" (x), "u" (one));
+    return res;
+}
+
+long double logl(long double x)
+{
+    long double one = 1;
+    long double res;
+    if (x <= 0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fyl2x;"
+        "fldl2e;"
+        "fdivp" : "=t" (res) : "0" (x), "u" (one));
+    return res;
+
+}
+
+
+double log10(double x)
+{
+    double one = 1;
+    double res;
+    if (x <= 0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fyl2x;"
+        "fldl2t;"
+        "fdivp" : "=t" (res) : "0" (x), "u" (one));
+    return res;
+
+}
+
+float log10f(float x)
+{
+    float one = 1;
+    float res;
+    if (x <= 0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fyl2x;"
+        "fldl2t;"
+        "fdivp" : "=t" (res) : "0" (x), "u" (one));
+    return res;
+
+}
+
+long double log10l(long double x)
+{
+    long double one = 1;
+    long double res;
+    if (x <= 0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fyl2x;"
+        "fldl2t;"
+        "fdivp" : "=t" (res) : "0" (x), "u" (one));
+    return res;
+
+}
+
diff --git a/src/modules/lib/stdlibc/math/fsin.c b/src/modules/lib/stdlibc/math/fsin.c
new file mode 100644
index 0000000..9748def
--- /dev/null
+++ b/src/modules/lib/stdlibc/math/fsin.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Patrick Kaufmann.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``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 COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS 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 "math.h"
+#include <errno.h>
+
+double sin(double x)
+{
+    double res;
+    asm("fsin" : "=t" (res) : "0" (x));
+    return res;
+}
+
+float sinf(float x)
+{
+    float res;
+    asm("fsin" : "=t" (res) : "0" (x));
+    return res;
+}
+
+long double sinl(long double x)
+{
+    long double res;
+    asm("fsin" : "=t" (res) : "0" (x));
+    return res;
+}
+
+double asin(double x) {
+    double res;
+    if (x <= -1 || x >= 1) {
+        errno = EDOM;
+        return NAN;
+    }
+    res = 2 * atan(x / (1 + sqrt(1 - (x * x))));
+    return res;
+}
+
+float asinf(float x) {
+    float res;
+    if (x <= -1 || x >= 1) {
+        errno = EDOM;
+        return NAN;
+    }
+    res = 2 * atan(x / (1 + sqrt(1 - (x * x))));
+    return res;
+}
+
+long double asinl(long double x) {
+    long double res;
+    if (x <= -1 || x >= 1) {
+        errno = EDOM;
+        return NAN;
+    }
+    res = 2 * atan(x / (1 + sqrt(1 - (x * x))));
+    return res;
+}
+
+
diff --git a/src/modules/lib/stdlibc/math/fsqrt.c b/src/modules/lib/stdlibc/math/fsqrt.c
new file mode 100644
index 0000000..1d9ac72
--- /dev/null
+++ b/src/modules/lib/stdlibc/math/fsqrt.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Patrick Kaufmann.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``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 COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS 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 "math.h"
+#include <errno.h>
+
+long double sqrtl(long double x)
+{
+    long double res;
+    if (x < 0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fsqrt" : "=t" (res) : "0" (x));
+    return res;
+}
+
+double sqrt(double x)
+{
+    double res;
+    if (x <  0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fsqrt" : "=l" (res) : "0" (x));
+    return res;
+}
+
+float sqrtf(float x)
+{
+    float res;
+    if (x < 0.0) {
+        errno = EDOM;
+        return NAN;
+    }
+    asm("fsqrt" : "=t" (res) : "0" (x));
+    return res;
+}
+
diff --git a/src/modules/lib/stdlibc/math/ftan.c b/src/modules/lib/stdlibc/math/ftan.c
new file mode 100644
index 0000000..de2f2ba
--- /dev/null
+++ b/src/modules/lib/stdlibc/math/ftan.c
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Patrick Kaufmann.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``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 COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS 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 "math.h"
+#include <errno.h>
+
+#define pi 3.1415926535897932384
+#define pio2 1.570796326794896619
+
+static short sgn(double x) {
+    short res;
+    if (x < 0) {
+        res =  -1;
+    } else if (x == 0) {
+        res =  0;
+    } else {
+        res =  1;
+    }
+    return res;
+}
+
+
+double tan(double x)
+{
+    double res;
+    asm("fptan" : "=t" (res) : "0" (x));
+    return res;
+}
+
+float tanf(float x)
+{
+    float res;
+    asm("fptan" : "=t" (res) : "0" (x));
+    return res;
+}
+
+long double tanl(long double x)
+{
+    long double res;
+    asm("fptan" : "=t" (res) : "0" (x));
+    return res;
+}
+
+double atan(double x)
+{
+    
+    double res;
+    asm("fld1; fpatan" : "=t" (res) : "0" (x));
+    return res;
+}
+
+float atanf(float x)
+{
+    float res;
+    asm("fld1; fpatan" : "=t" (res) : "0" (x));
+    return res;
+}
+
+
+long double atanl(long double x)
+{
+    long double res;
+    asm("fld1; fpatan" : "=t" (res) : "0" (x));
+    return res;
+}
+
+double atan2(double x, double y) {
+    double res;
+    if (x < 0) {
+        res = (pi - atan(y / x)) * sgn(y);
+        return res;
+    } else if (x == 0) {
+        if (y == 0) {
+            errno = EDOM;
+            return NAN;
+        }
+        res = pio2 * sgn(y);
+        return res;
+    }
+    res = atan(y / x) * sgn(y);
+    return res;
+}
+
+
+float atan2f(float x, float y) {
+    float res;
+    if (x < 0) {
+        res = (pi - atan(y / x)) * (float)sgn((double)y);
+        return res;
+    } else if (x == 0) {
+        if (y == 0) {
+            errno = EDOM;
+            return NAN;
+        }
+        res = pio2 * (float)sgn((double)y);
+        return res;
+    }
+    res = atan(y / x) * (float)sgn((double)y);
+    return res;
+}
+
+long double atan2l(long double x, long double y) {
+    long double res;
+    if (x < 0) {
+        res = (pi - atan(y / x)) * (long double)sgn((double)y);
+        return res;
+    } else if (x == 0) {
+        if (y == 0) {
+            errno = EDOM;
+            return NAN;
+        }
+        res = pio2 * (long double)sgn((double)y);
+        return res;
+    }
+    res = atan(y / x) * (long double)sgn((double)y);
+    return res;
+}
+
-- 
1.6.3.3