about summary refs log tree commit diff
path: root/src/stdlib/wcstoull.c
blob: 48c557db59d77889e8095098c7478cd7a0d37fd0 (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>

unsigned long long wcstoull(const wchar_t *s, wchar_t **p, int base)
{
 	intmax_t x;
	if (sizeof(intmax_t) == sizeof(long long))
		return wcstoumax(s, p, base);
	x = wcstoimax(s, p, base);
	if (-x > ULLONG_MAX || x > ULLONG_MAX) {
		errno = ERANGE;
		return ULLONG_MAX;
	}
	return x;
}