diff options
author | Vic Yang <victoryang@chromium.org> | 2014-05-19 15:03:27 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-05-21 20:32:17 +0000 |
commit | ffac23c0ea1bd4ff4568f5bd709a98f912b833a7 (patch) | |
tree | 362dd0ba205731aa07be97dd35b44b237799b23b /include/console.h | |
parent | 478361de694b1fb45abf3c38dafbbf7fd1aa5f71 (diff) | |
download | chrome-ec-ffac23c0ea1bd4ff4568f5bd709a98f912b833a7.tar.gz |
Add cprints() and ccprints()
Our code base contains a lot of debug messages in this pattern:
CPRINTF("[%T xxx]\n") or ccprintf("[%T xxx]\n")
The strings are taking up spaces in the EC binaries, so let's refactor
this by adding cprints() and ccprints().
cprints() is just like cprintf(), except that it adds the brackets
and the timestamp. ccprints() is equivalent to cprints(CC_CONSOLE, ...)
This saves us hundreds of bytes in EC binaries.
BUG=chromium:374575
TEST=Build and check flash size
BRANCH=None
Change-Id: Ifafe8dc1b80e698b28ed42b70518c7917b49ee51
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/200490
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'include/console.h')
-rw-r--r-- | include/console.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/console.h b/include/console.h index 5cd02bb5c8..f2113cda00 100644 --- a/include/console.h +++ b/include/console.h @@ -85,6 +85,17 @@ int cputs(enum console_channel channel, const char *outstr); int cprintf(enum console_channel channel, const char *format, ...); /** + * Print formatted output with timestamp. This is like: + * cprintf(channel, "[%T " + format + "]\n", ...) + * + * @param channel Output channel + * @param format Format string; see printf.h for valid formatting codes + * + * @return non-zero if output was truncated. + */ +int cprints(enum console_channel channel, const char *format, ...); + +/** * Flush the console output for all channels. */ void cflush(void); @@ -97,6 +108,7 @@ void cflush(void); /* gcc allows variable arg lists in macros; see * http://gcc.gnu.org/onlinedocs/gcc/Variadic-Macros.html */ #define ccprintf(format, args...) cprintf(CC_COMMAND, format, ## args) +#define ccprints(format, args...) cprints(CC_COMMAND, format, ## args) /** * Called by UART when a line of input is pending. |