diff options
author | Dan Albert <danalbert@google.com> | 2016-10-06 15:46:45 -0700 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2016-10-20 10:10:45 -0700 |
commit | 3037ea43fccf5ec64537c3ee024bc726ee723c01 (patch) | |
tree | 830fda3221eb1207bb837f78298032be2d2c1706 /libc/include/stdio.h | |
parent | d8244214751f9b48e60e69910c4e7175f8fab1ac (diff) |
Fix stdin/stdout/stderr for pre-M.
This wasn't an array of pointers, it was an array of structs.
Unfortunately we need a complete type to index into the struct for
stdin/stdout/stderr, so add a phony struct that matches the size and
alignment of `struct __sFILE`. This property is guaranteed by the
static_asserts in libc/bionic/struct_file_test.cpp.
Test: mma
Bug: http://b/30465923
Change-Id: I8ce851dd64a261703bb44f9b5cd23b7caff4dd68
Diffstat (limited to 'libc/include/stdio.h')
-rw-r--r-- | libc/include/stdio.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libc/include/stdio.h b/libc/include/stdio.h index 38021efe9..816bd282a 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -49,6 +49,10 @@ #include <bits/seek_constants.h> +#if __ANDROID_API__ <= 23 +#include <bits/struct_file.h> +#endif + __BEGIN_DECLS #if defined(__clang__) @@ -73,11 +77,11 @@ extern FILE* stderr __INTRODUCED_IN(23); #define stderr stderr #else /* Before M the actual symbols for stdin and friends had different names. */ -extern FILE* __sF[] __REMOVED_IN(23); +extern FILE __sF[] __REMOVED_IN(23); -#define stdin __sF[0] -#define stdout __sF[1] -#define stderr __sF[2] +#define stdin (&__sF[0]) +#define stdout (&__sF[1]) +#define stderr (&__sF[2]) #endif /* |