From patchwork Sat Sep 16 05:10:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 112780 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1391854qgf; Fri, 15 Sep 2017 22:14:57 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA2ANS/Qh1V1JAvtJhex9LTJ7dGvkfFktPxSbbql7s4SVVvUJEt5YSc+LGMPFbney8NpUao X-Received: by 10.80.215.206 with SMTP id m14mr9485044edj.81.1505538897071; Fri, 15 Sep 2017 22:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505538897; cv=none; d=google.com; s=arc-20160816; b=w5IMDyrR5S5zM+68Xu06fnfdt9bBONvz+Dj4oobjOV7hj1NY1LPadtLzVtlIAnFA6B Litxlo26FRvHrB9tA8RsoACzGC9BxMro9BCD5vl0+tJJSXBuw6mlnFTtODxt/Ue5ykoQ iO+bRKpcJjVjWRepIM5dANT8abac+jzdN9pEUd82N8J8TMe1/gSG7OuLnzynfTObf0Ua S1mCLU41RhGjIWKrLp+8f4kj2FxwMBQeRHH0WHq5aN09E0jrrvTFdyefoBaF6L4WFeH9 MXAGjJ85rj49SzhHJzjIawFpY9AHEXekaubQaIHl2gXn4EauWUqz+hGYm6CrYG0sIzV9 N2Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:dkim-filter:arc-authentication-results; bh=oQr7EVx5xYr/89dXTtNGKbctpCaZ0kh8S9swxvM2EbQ=; b=lZymiMhxICQIQsmS807YdaAhgTqt1GPbzg80phcMw/jRUrlBopWIHxuLCOxp6R9P3W ibHgpj128vOMlB1K2LrSrWm27I0LZjvRPV3VVH029+JALpotKJ6JUzbok3iF99ltD9B1 bnJwnxqY5WfW6zEbWjSRAj8kQsdL7ZvEpVGe3o/zXVRyRWUOXjxOZc++cXhvxXnWDfV+ yjxdfvLfPPuaoh4eyLTYVqlgkNsFp7A1VjhMZStk1lFa88CebPWuu6XUG8twy/yVW7Om M5pGdYmSa1rNKPlkPyNdVZzxLpXwh5QuOuUcI7b4zEpxhSiBdmQiAOQD4CcMCrZ4FXtm J+JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=VTbcDm97; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id m35si2796107ede.503.2017.09.15.22.14.56; Fri, 15 Sep 2017 22:14:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=VTbcDm97; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id B0C68C21F7E; Sat, 16 Sep 2017 05:12:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 1FC9FC21FAB; Sat, 16 Sep 2017 05:11:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A9682C21C41; Sat, 16 Sep 2017 05:11:18 +0000 (UTC) Received: from conuserg-09.nifty.com (conuserg-09.nifty.com [210.131.2.76]) by lists.denx.de (Postfix) with ESMTPS id B1285C21C41 for ; Sat, 16 Sep 2017 05:11:16 +0000 (UTC) Received: from grover.sesame (FL1-122-131-185-176.osk.mesh.ad.jp [122.131.185.176]) (authenticated) by conuserg-09.nifty.com with ESMTP id v8G5Asol028761; Sat, 16 Sep 2017 14:10:56 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com v8G5Asol028761 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1505538656; bh=NAljXx8AcMwU5sS5IUYklvz41UUUv7VYi0m5AmnP74k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VTbcDm97Uw/SoW9eWaCk0US6RQbubGq5JyJj0hxP4FYCJiZG8bkUDN8ZvNZIiCWmI No85BgKvHCZ+gZ9f3ml06JUaSmlRGH0qTBXLOfDrt0vLI8FndBKqRWL9ncOi1muCwv th5fZKgaN4qoEmrNn+iEVwQL53D5YWomWb1m6F/YM6aZNmwDyJ0lLbHUC+0m1QdXMd aa/Ayc+BjjQvYpL1+YsXdDwTSMyTF3qAwC6f7JFFJDDNEYB9z9v2ZyfnoV82kR3cR5 2An9UzOSGzJZgyyeQkHnYhYLOyUzXEhdFnPKqE2lZIdXPR2UhS34NbCJ3GJA/2exIa B6kjbRf64BEsA== X-Nifty-SrcIP: [122.131.185.176] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Sat, 16 Sep 2017 14:10:39 +0900 Message-Id: <1505538646-19191-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505538646-19191-1-git-send-email-yamada.masahiro@socionext.com> References: <1505538646-19191-1-git-send-email-yamada.masahiro@socionext.com> Subject: [U-Boot] [PATCH v2 1/8] stdio.h: move printf() stuff from to X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" pulls in a lot of headers. Including it from every .c file is a bad idea. We need to remove contents until it contains nothing. Move printf() and friends to . Signed-off-by: Masahiro Yamada --- Changes in v2: - newly added include/common.h | 41 +-------------------------------------- include/stdio.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 40 deletions(-) create mode 100644 include/stdio.h diff --git a/include/common.h b/include/common.h index aaed13167123..5e841947c17f 100644 --- a/include/common.h +++ b/include/common.h @@ -29,6 +29,7 @@ typedef volatile unsigned char vu_char; #include #include #include +#include #include #include @@ -699,46 +700,6 @@ unsigned int rand_r(unsigned int *seedp); /* serial stuff */ int serial_printf (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); -/* stdin */ -int getc(void); -int tstc(void); - -/* stdout */ -#if !defined(CONFIG_SPL_BUILD) || \ - (defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL_SUPPORT)) || \ - (defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \ - defined(CONFIG_SPL_SERIAL_SUPPORT)) -void putc(const char c); -void puts(const char *s); -int printf(const char *fmt, ...) - __attribute__ ((format (__printf__, 1, 2))); -int vprintf(const char *fmt, va_list args); -#else -#define putc(...) do { } while (0) -#define puts(...) do { } while (0) -#define printf(...) do { } while (0) -#define vprintf(...) do { } while (0) -#endif - -/* stderr */ -#define eputc(c) fputc(stderr, c) -#define eputs(s) fputs(stderr, s) -#define eprintf(fmt,args...) fprintf(stderr,fmt ,##args) - -/* - * FILE based functions (can only be used AFTER relocation!) - */ -#define stdin 0 -#define stdout 1 -#define stderr 2 -#define MAX_FILES 3 - -int fprintf(int file, const char *fmt, ...) - __attribute__ ((format (__printf__, 2, 3))); -void fputs(int file, const char *s); -void fputc(int file, const char c); -int ftstc(int file); -int fgetc(int file); /* lib/gzip.c */ int gzip(void *dst, unsigned long *lenp, diff --git a/include/stdio.h b/include/stdio.h new file mode 100644 index 000000000000..aedf3744525e --- /dev/null +++ b/include/stdio.h @@ -0,0 +1,59 @@ +#ifndef __STDIO_H +#define __STDIO_H + +#include +#include + +/* stdin */ +int getc(void); +int tstc(void); + +/* stdout */ +#if !defined(CONFIG_SPL_BUILD) || \ + (defined(CONFIG_TPL_BUILD) && defined(CONFIG_TPL_SERIAL_SUPPORT)) || \ + (defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \ + defined(CONFIG_SPL_SERIAL_SUPPORT)) +void putc(const char c); +void puts(const char *s); +int __printf(1, 2) printf(const char *fmt, ...); +int vprintf(const char *fmt, va_list args); +#else +static inline void putc(const char c) +{ +} + +static inline void puts(const char *s) +{ +} + +static inline int __printf(1, 2) printf(const char *fmt, ...) +{ + return 0; +} + +static inline int vprintf(const char *fmt, va_list args) +{ + return 0; +} +#endif + +/* + * FILE based functions (can only be used AFTER relocation!) + */ +#define stdin 0 +#define stdout 1 +#define stderr 2 +#define MAX_FILES 3 + +/* stderr */ +#define eputc(c) fputc(stderr, c) +#define eputs(s) fputs(stderr, s) +#define eprintf(fmt, args...) fprintf(stderr, fmt, ##args) + +int __printf(2, 3) fprintf(int file, const char *fmt, ...); +void fputs(int file, const char *s); +void fputc(int file, const char c); +int ftstc(int file); +int fgetc(int file); + +#endif /* __STDIO_H */