From patchwork Tue Oct 25 03:59:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 121479 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id DFD10B6F76 for ; Tue, 25 Oct 2011 15:01:26 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 111B528DFD; Tue, 25 Oct 2011 06:01:22 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vuG16Tnl0MxW; Tue, 25 Oct 2011 06:01:21 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 09E9328D6D; Tue, 25 Oct 2011 06:01:09 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 748B128C9D for ; Tue, 25 Oct 2011 06:00:50 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GTFoyk8Y8GM8 for ; Tue, 25 Oct 2011 06:00:50 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp-out.google.com (smtp-out.google.com [74.125.121.67]) by theia.denx.de (Postfix) with ESMTPS id 1876B28C76 for ; Tue, 25 Oct 2011 06:00:47 +0200 (CEST) Received: from wpaz17.hot.corp.google.com (wpaz17.hot.corp.google.com [172.24.198.81]) by smtp-out.google.com with ESMTP id p9P40eVR002937; Mon, 24 Oct 2011 21:00:40 -0700 Received: from glucid-laptop-imager.hot.corp.google.com ([172.19.243.42]) by wpaz17.hot.corp.google.com with ESMTP id p9P40dbZ007214; Mon, 24 Oct 2011 21:00:39 -0700 Received: by glucid-laptop-imager.hot.corp.google.com (Postfix, from userid 121222) id F249D34E6A7; Mon, 24 Oct 2011 21:00:38 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 24 Oct 2011 20:59:58 -0700 Message-Id: <1319515208-7810-2-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.3.1 In-Reply-To: <1319515208-7810-1-git-send-email-sjg@chromium.org> References: <1319515208-7810-1-git-send-email-sjg@chromium.org> X-System-Of-Record: true Subject: [U-Boot] [PATCH v2 01/11] Move simple_itoa() to vsprintf.c X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de This function is generally useful and shouldn't hide away in hush. It has been moved as is. Signed-off-by: Simon Glass --- common/hush.c | 15 --------------- include/common.h | 1 + lib/vsprintf.c | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/common/hush.c b/common/hush.c index 940889b..2495a6d 100644 --- a/common/hush.c +++ b/common/hush.c @@ -17,7 +17,6 @@ * Erik W. Troan, which they placed in the public domain. I don't know * how much of the Johnson/Troan code has survived the repeated rewrites. * Other credits: - * simple_itoa() was lifted from boa-0.93.15 * b_addchr() derived from similar w_addchar function in glibc-2.2 * setup_redirect(), redirect_opt_num(), and big chunks of main() * and many builtins derived from contributions by Erik Andersen @@ -922,20 +921,6 @@ static int b_addqchr(o_string *o, int ch, int quote) return b_addchr(o, ch); } -/* belongs in utility.c */ -char *simple_itoa(unsigned int i) -{ - /* 21 digits plus null terminator, good for 64-bit or smaller ints */ - static char local[22]; - char *p = &local[21]; - *p-- = '\0'; - do { - *p-- = '0' + i % 10; - i /= 10; - } while (i > 0); - return p + 1; -} - #ifndef __U_BOOT__ static int b_adduint(o_string *o, unsigned int i) { diff --git a/include/common.h b/include/common.h index a1683a2..4329802 100644 --- a/include/common.h +++ b/include/common.h @@ -723,6 +723,7 @@ void panic(const char *fmt, ...) int sprintf(char * buf, const char *fmt, ...) __attribute__ ((format (__printf__, 2, 3))); int vsprintf(char *buf, const char *fmt, va_list args); +char *simple_itoa(ulong i); /* lib/strmhz.c */ char * strmhz(char *buf, unsigned long hz); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 79dead3..e497a86 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -7,6 +7,8 @@ /* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */ /* * Wirzenius wrote this portably, Torvalds fucked it up :-) + * + * from hush: simple_itoa() was lifted from boa-0.93.15 */ #include @@ -738,3 +740,17 @@ void __assert_fail(const char *assertion, const char *file, unsigned line, panic("%s:%u: %s: Assertion `%s' failed.", file, line, function, assertion); } + +char *simple_itoa(ulong i) +{ + /* 21 digits plus null terminator, good for 64-bit or smaller ints */ + static char local[22]; + char *p = &local[21]; + + *p-- = '\0'; + do { + *p-- = '0' + i % 10; + i /= 10; + } while (i > 0); + return p + 1; +}