From 430cf1a6c32471ada4dad028acbfcc032da01fd3 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 3 Jun 2014 14:45:17 -0700 Subject: [PATCH] DO NOT MERGE fdprintf backward compatibility shim. Fixes LP64 build. Change-Id: Ic76005cd1f5a55344ea8ee3d070d25631d011037 --- libc/bionic/ndk_cruft.cpp | 9 --------- libc/include/stdio.h | 9 ++++++++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libc/bionic/ndk_cruft.cpp b/libc/bionic/ndk_cruft.cpp index 1284b9a4e..f680fe0d0 100644 --- a/libc/bionic/ndk_cruft.cpp +++ b/libc/bionic/ndk_cruft.cpp @@ -186,15 +186,6 @@ extern "C" intmax_t strntoimax(const char* nptr, char** endptr, int base, size_t return (intmax_t) strntoumax(nptr, endptr, base, n); } -// POSIX calls this dprintf, but LP32 Android had fdprintf instead. -extern "C" int fdprintf(int fd, const char* fmt, ...) { - va_list ap; - va_start(ap, fmt); - int rc = vdprintf(fd, fmt, ap); - va_end(ap); - return rc; -} - // POSIX calls this vdprintf, but LP32 Android had fdprintf instead. extern "C" int vfdprintf(int fd, const char* fmt, va_list ap) { return vdprintf(fd, fmt, ap); diff --git a/libc/include/stdio.h b/libc/include/stdio.h index c6b2d3226..8f3c525d7 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -253,7 +253,14 @@ int vprintf(const char * __restrict, __va_list) int dprintf(int, const char * __restrict, ...) __printflike(2, 3); int vdprintf(int, const char * __restrict, __va_list) __printflike(2, 0); -int fdprintf(int, const char * __restrict, ...) __printflike(2, 3); /* Note: this is only in the preview release. */ +static inline int fdprintf(int fd, const char* fmt, ...) { + /* Note: this backward compatibility shim is only in the preview release. */ + va_list ap; + va_start(ap, fmt); + int rc = vdprintf(fd, fmt, ap); + va_end(ap); + return rc; +} #ifndef __AUDIT__ char* gets(char*) __warnattr("gets is very unsafe; consider using fgets");