diff options
author | Ayrton Munoz <ayrton@google.com> | 2022-06-14 10:59:29 -0400 |
---|---|---|
committer | Ayrton Munoz <ayrton@google.com> | 2022-09-23 15:10:54 -0400 |
commit | 68e04bfc9a24760c3efe6ca6342ec3d2d38db1c2 (patch) | |
tree | a0e2b503f8591a9d4df48959a66ae093659929c6 /lib | |
parent | 2d03136fc8e18048137037dc014b6a55fe392785 (diff) | |
download | common-68e04bfc9a24760c3efe6ca6342ec3d2d38db1c2.tar.gz |
lib/libc: Rename _printf and _vprintf to printf and vprintf
LK's stdio.h previously defined a printf macro which
expanded to _printf when DISABLE_DEBUG_OUTPUT was 0. However
libcxx expects a symbol named printf in the global namespace
so this commit renames _printf to printf to allow compiling
C++ while still being able to disable debug output.
Bug: 230134581
Change-Id: I0b2d017c70302389606d7548408ccc40c95b36da
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/include/stdio.h | 12 | ||||
-rw-r--r-- | lib/libc/stdio.c | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/lib/libc/include/stdio.h b/lib/libc/include/stdio.h index 3b4e968f..01315da5 100644 --- a/lib/libc/include/stdio.h +++ b/lib/libc/include/stdio.h @@ -64,16 +64,8 @@ int puts(const char *str); int getc(FILE *fp); int getchar(void); -#if !DISABLE_DEBUG_OUTPUT -#define printf(x...) _printf(x) -#define vprintf(x...) _vprintf(x) -#else -static inline int __PRINTFLIKE(1, 2) printf(const char *fmt, ...) { return 0; } -static inline int vprintf(const char *fmt, va_list ap) { return 0; } -#endif - -int _printf(const char *fmt, ...) __PRINTFLIKE(1, 2); -int _vprintf(const char *fmt, va_list ap); +int printf(const char *fmt, ...) __PRINTFLIKE(1, 2); +int vprintf(const char *fmt, va_list ap); int fprintf(FILE *fp, const char *fmt, ...) __PRINTFLIKE(2, 3); int vfprintf(FILE *fp, const char *fmt, va_list ap); diff --git a/lib/libc/stdio.c b/lib/libc/stdio.c index a8a29590..e9ee106d 100644 --- a/lib/libc/stdio.c +++ b/lib/libc/stdio.c @@ -128,8 +128,11 @@ int fprintf(FILE *fp, const char *fmt, ...) return err; } -int _printf(const char *fmt, ...) +int printf(const char *fmt, ...) { +#if DISABLE_DEBUG_OUTPUT + return 0; +#else va_list ap; int err; @@ -138,9 +141,14 @@ int _printf(const char *fmt, ...) va_end(ap); return err; +#endif } -int _vprintf(const char *fmt, va_list ap) +int vprintf(const char *fmt, va_list ap) { +#if DISABLE_DEBUG_OUTPUT + return 0; +#else return vfprintf(stdout, fmt, ap); +#endif } |