Rev | Line | |
---|
[1] | 1 | #include <endian.h> |
---|
| 2 | #include <ctype.h> |
---|
| 3 | #include <stdlib.h> |
---|
| 4 | |
---|
| 5 | long 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 |
---|
| 20 | long long int atoll(const char* s) __attribute__((alias("atol"))); |
---|
| 21 | #else |
---|
| 22 | int atoi(const char* s) __attribute__((alias("atol"))); |
---|
| 23 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.