summaryrefslogtreecommitdiff
path: root/src/stdlib/strtoull.c
blob: 20aa7bdeca007db15083572dbd3620dabdff1858 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdlib.h>
#include <inttypes.h>
#include <errno.h>
#include <limits.h>

unsigned long long strtoull(const char *s, char **p, int base)
{
	uintmax_t x = strtoumax(s, p, base);
	if (x > ULLONG_MAX) {
		errno = ERANGE;
		return ULLONG_MAX;
	}
	return x;
}