diff options
Diffstat (limited to 'src/stdlib/strtoll.c')
-rw-r--r-- | src/stdlib/strtoll.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/stdlib/strtoll.c b/src/stdlib/strtoll.c new file mode 100644 index 0000000..9ab66fd --- /dev/null +++ b/src/stdlib/strtoll.c @@ -0,0 +1,17 @@ +#include <stdlib.h> +#include <inttypes.h> +#include <errno.h> +#include <limits.h> + +long long strtoll(const char *s, char **p, int base) +{ + intmax_t x = strtoimax(s, p, base); + if (x > LLONG_MAX) { + errno = ERANGE; + return LLONG_MAX; + } else if (x < LLONG_MIN) { + errno = ERANGE; + return LLONG_MIN; + } + return x; +} |