summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/lib/atoll.c
blob: 7bf2b2fd677f2e8766e54b44adbefbbbb44af55f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <endian.h>
#include <ctype.h>
#include <stdlib.h>

#if __WORDSIZE != 64
long long int atoll(const char* s) {
  long long int v=0;
  int sign=1;
  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==-1?-v:v;
}
#endif