From afe2234fb10053af0401050d81a4ee985a08504f Mon Sep 17 00:00:00 2001 From: Pixel Date: Sat, 5 Feb 2011 13:15:32 -0800 Subject: Adding a few more stdlib functions. --- libc/LIB.status | 6 +++--- libc/include/stdlib.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'libc') 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 #include +#include 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 -- cgit v1.2.3