fix incorrect overflow errors on strtoul, etc.
[musl] / src / stdlib / strtoll.c
1 #include <stdlib.h>
2 #include <inttypes.h>
3 #include <errno.h>
4 #include <limits.h>
5
6 long long strtoll(const char *s, char **p, int base)
7 {
8         intmax_t x = strtoimax(s, p, base);
9         if (x > LLONG_MAX) {
10                 errno = ERANGE;
11                 return LLONG_MAX;
12         } else if (x < LLONG_MIN) {
13                 errno = ERANGE;
14                 return LLONG_MIN;
15         }
16         return x;
17 }