diff options
| author | [email protected] <[email protected]> | 2012-07-12 22:42:06 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2012-07-12 22:42:06 +0000 |
| commit | 70cee4b82eb05b0979df7bd999be38ce3b12b76c (patch) | |
| tree | a8131f3eb6491c4080979034cfdbb96b7a9f5142 /components/libc/minilibc/stdlib.c | |
| parent | ae3c1800d4e8c2feabd2f09bd164ddb8b0614f7d (diff) | |
add atol and isspace to minilibc.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2218 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/libc/minilibc/stdlib.c')
| -rw-r--r-- | components/libc/minilibc/stdlib.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/components/libc/minilibc/stdlib.c b/components/libc/minilibc/stdlib.c index cac4ae5691..7185f56bb7 100644 --- a/components/libc/minilibc/stdlib.c +++ b/components/libc/minilibc/stdlib.c @@ -37,6 +37,23 @@ int atoi(const char* s) return sign==-1?-v:v;
}
+long int atol(const char* s)
+{
+ long int v=0;
+ int sign=0;
+ while ( *s == ' ' || (unsigned int)(*s - 9) < 5u) ++s;
+ switch (*s)
+ {
+ case '-': sign=-1;
+ case '+': ++s;
+ }
+ while ((unsigned int) (*s - '0') < 10u)
+ {
+ v=v*10+*s-'0'; ++s;
+ }
+ return sign?-v:v;
+}
+
void *malloc(size_t size)
{
return rt_malloc(size);
|
