wcstoull.c 387 B

123456789101112131415161718
  1. #include <wchar.h>
  2. #include <stdlib.h>
  3. #include <inttypes.h>
  4. #include <errno.h>
  5. #include <limits.h>
  6. unsigned long long wcstoull(const wchar_t *s, wchar_t **p, int base)
  7. {
  8. intmax_t x;
  9. if (sizeof(intmax_t) == sizeof(long long))
  10. return wcstoumax(s, p, base);
  11. x = wcstoimax(s, p, base);
  12. if (-x > ULLONG_MAX || x > ULLONG_MAX) {
  13. errno = ERANGE;
  14. return ULLONG_MAX;
  15. }
  16. return x;
  17. }