summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-02-05 13:15:32 -0800
committerPixel <pixel@nobis-crew.org>2011-02-05 13:20:18 -0800
commitafe2234fb10053af0401050d81a4ee985a08504f (patch)
tree69f4765989183b1180ed81eb0b4e12f1cad891a5
parent078b4ccf0b65d655d81e9f4fc6e1284773e1dda4 (diff)
Adding a few more stdlib functions.
-rw-r--r--libc/LIB.status6
-rw-r--r--libc/include/stdlib.h5
2 files changed, 8 insertions, 3 deletions
diff --git a/libc/LIB.status b/libc/LIB.status
index 7ef0748..bd8fcf0 100644
--- a/libc/LIB.status
+++ b/libc/LIB.status
@@ -3,9 +3,9 @@ Stdlib:
What should stdlib contain, and current status.
-atof - missing
-atoi - missing
-atol - missing
+atof - ok, inlined, bound to sscanf
+atoi - ok, inlined, bound to sscanf, will read hex and octal
+atol - ok, inlined, bound to sscanf, will read hex and octal
strtod - missing
strtof - missing
strtold - missing (do we want to support long double anyway?)
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 5654950..f9f2a94 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -3,6 +3,7 @@
#include <reent.h>
#include <malloc.h>
+#include <stdio.h>
typedef void (*atexit_func_t)(void);
@@ -11,4 +12,8 @@ int atexit(atexit_func_t);
void qsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *));
+static inline double atof(const char * str) { double r = 0; sscanf(str, "%lf", &r); return r; }
+static inline int atoi(const char * str) { int i; sscanf(str, "%i", &i); return i; }
+static inline int atol(const char * str) { long l; sscanf(str, "%li", &l); return l; }
+
#endif