summaryrefslogtreecommitdiff
path: root/src/stdlib/wcstoll.c
blob: ddfea74bd15de8dde96348e0fd6df16b6a0f6adc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <wchar.h>
#include <stdlib.h>
#include <inttypes.h>
#include <errno.h>
#include <limits.h>

long long wcstoll(const wchar_t *s, wchar_t **p, int base)
{
	intmax_t x = wcstoimax(s, p, base);
	if (x > LLONG_MAX) {
		errno = ERANGE;
		return LLONG_MAX;
	} else if (x < LLONG_MIN) {
		errno = ERANGE;
		return LLONG_MIN;
	}
	return x;
}