OpenCores
URL https://opencores.org/ocsvn/or1k_soc_on_altera_embedded_dev_kit/or1k_soc_on_altera_embedded_dev_kit/trunk

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [linux-2.6/] [linux-2.6.24/] [arch/] [powerpc/] [boot/] [stdlib.c] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 xianfeng
/*
2
 * stdlib functions
3
 *
4
 * Author: Scott Wood <scottwood@freescale.com>
5
 *
6
 * Copyright (c) 2007 Freescale Semiconductor, Inc.
7
 *
8
 * This program is free software; you can redistribute it and/or modify it
9
 * under the terms of the GNU General Public License version 2 as published
10
 * by the Free Software Foundation.
11
 */
12
 
13
#include "stdlib.h"
14
 
15
/* Not currently supported: leading whitespace, sign, 0x prefix, zero base */
16
unsigned long long int strtoull(const char *ptr, char **end, int base)
17
{
18
        unsigned long long ret = 0;
19
 
20
        if (base > 36)
21
                goto out;
22
 
23
        while (*ptr) {
24
                int digit;
25
 
26
                if (*ptr >= '0' && *ptr <= '9' && *ptr < '0' + base)
27
                        digit = *ptr - '0';
28
                else if (*ptr >= 'A' && *ptr < 'A' + base - 10)
29
                        digit = *ptr - 'A' + 10;
30
                else if (*ptr >= 'a' && *ptr < 'a' + base - 10)
31
                        digit = *ptr - 'a' + 10;
32
                else
33
                        break;
34
 
35
                ret *= base;
36
                ret += digit;
37
                ptr++;
38
        }
39
 
40
out:
41
        if (end)
42
                *end = (char *)ptr;
43
 
44
        return ret;
45
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.