source: trunk/sys/dietlibc/atoi.c @ 6

Last change on this file since 6 was 1, checked in by alain, 7 years ago

First import

File size: 359 bytes
Line 
1#include <endian.h>
2#include <ctype.h>
3#include <stdlib.h>
4
5#if __WORDSIZE == 64
6int atoi(const char* s) {
7  long int v=0;
8  int sign=1;
9  while ( *s == ' '  ||  (unsigned int)(*s - 9) < 5u) s++;
10  switch (*s) {
11  case '-': sign=-1;
12  case '+': ++s;
13  }
14  while ((unsigned int) (*s - '0') < 10u) {
15    v=v*10+*s-'0'; ++s;
16  }
17  return sign==-1?-v:v;
18}
19#endif
Note: See TracBrowser for help on using the repository browser.