File: atol.c

package info (click to toggle)
dietlibc 0.34~cvs20160606-12
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 11,388 kB
  • sloc: ansic: 71,664; asm: 13,008; cpp: 1,860; makefile: 804; sh: 292; perl: 62
file content (23 lines) | stat: -rw-r--r-- 509 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <endian.h>
#include <ctype.h>
#include <stdlib.h>

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;	/* fall through */
  case '+': ++s;
  }
  while ((unsigned int) (*s - '0') < 10u) {
    v=v*10+*s-'0'; ++s;
  }
  return sign?-v:v;
}

#if __WORDSIZE == 64
long long int atoll(const char* s) __attribute__((alias("atol")));
#else
int atoi(const char* s) __attribute__((alias("atol")));
#endif