From 598f37043a434145c8afc26767689552499e8d50 Mon Sep 17 00:00:00 2001 From: Allen Webb Date: Thu, 30 May 2019 11:16:53 -0700 Subject: 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 Reviewed-on: https://chromium-review.googlesource.com/1637580 Legacy-Commit-Queue: Commit Bot Reviewed-by: Nicolas Boichat --- include/printf.h | 13 +++++++++---- 1 file 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 */ -- cgit v1.2.1