source: trunk/sys/dietlibc/atol.c @ 53

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

First import

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