summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllen Webb <allenwebb@google.com>2019-05-30 11:16:53 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-06-03 17:18:35 -0700
commit598f37043a434145c8afc26767689552499e8d50 (patch)
tree2fe842a8ec49965bf2aa9347a7f3809e1898c5a2
parent0036edd5f4f4215a2a8ed3c13a6c82ad0fc1f39f (diff)
downloadchrome-ec-598f37043a434145c8afc26767689552499e8d50.tar.gz
printf: Add HIDE_EC_STDLIB and __stdlib_compat defines.
Fuzzing targets are linked against libec.a so that they can invoke ec functionality while depending on outside libraries that need cstdlib. An issue was being hit with a libprotobuf-mutator fuzzer target because protobuf needed the stdlib version of vfnprintf. This change resolves the issue by keeping the EC version of vfnprinf within libec.a. BRANCH=none BUG=chromium:962947 TEST=make -j buildall Change-Id: Ie0c79199dfba58d5fb04d9f340967a73921d09c8 Signed-off-by: Allen Webb <allenwebb@google.com> Reviewed-on: https://chromium-review.googlesource.com/1637580 Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r--include/printf.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/printf.h b/include/printf.h
index 441a7968f3..f22f8651ba 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -55,6 +55,8 @@
* This does NOT use up any arguments.
*/
+#ifndef HIDE_EC_STDLIB
+
/**
* Print formatted output to a function, like vfprintf()
*
@@ -68,8 +70,8 @@
* @param args Parameters
* @return EC_SUCCESS, or non-zero if output was truncated.
*/
-int vfnprintf(int (*addchar)(void *context, int c), void *context,
- const char *format, va_list args);
+__stdlib_compat int vfnprintf(int (*addchar)(void *context, int c),
+ void *context, const char *format, va_list args);
/**
* Print formatted outut to a string.
@@ -81,7 +83,7 @@ int vfnprintf(int (*addchar)(void *context, int c), void *context,
* @param format Format string
* @return EC_SUCCESS, or non-zero if output was truncated.
*/
-int snprintf(char *str, int size, const char *format, ...);
+__stdlib_compat int snprintf(char *str, int size, const char *format, ...);
/**
* Print formatted outut to a string.
@@ -94,6 +96,9 @@ int snprintf(char *str, int size, const char *format, ...);
* @param args Parameters
* @return EC_SUCCESS, or non-zero if output was truncated.
*/
-int vsnprintf(char *str, int size, const char *format, va_list args);
+__stdlib_compat int vsnprintf(char *str, int size, const char *format,
+ va_list args);
+
+#endif /* !HIDE_EC_STDLIB */
#endif /* __CROS_EC_PRINTF_H */