Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / powerpc / boot / stdlib.c
blob868b019d6384e731ab107862df31e26e359a6f3e
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * stdlib functions
5 * Author: Scott Wood <scottwood@freescale.com>
7 * Copyright (c) 2007 Freescale Semiconductor, Inc.
8 */
10 #include "stdlib.h"
12 /* Not currently supported: leading whitespace, sign, 0x prefix, zero base */
13 unsigned long long int strtoull(const char *ptr, char **end, int base)
15 unsigned long long ret = 0;
17 if (base > 36)
18 goto out;
20 while (*ptr) {
21 int digit;
23 if (*ptr >= '0' && *ptr <= '9' && *ptr < '0' + base)
24 digit = *ptr - '0';
25 else if (*ptr >= 'A' && *ptr < 'A' + base - 10)
26 digit = *ptr - 'A' + 10;
27 else if (*ptr >= 'a' && *ptr < 'a' + base - 10)
28 digit = *ptr - 'a' + 10;
29 else
30 break;
32 ret *= base;
33 ret += digit;
34 ptr++;
37 out:
38 if (end)
39 *end = (char *)ptr;
41 return ret;