summaryrefslogtreecommitdiff
path: root/libc/stdio/stdio.cpp
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2016-10-06 15:46:45 -0700
committerDan Albert <danalbert@google.com>2016-10-20 10:10:45 -0700
commit3037ea43fccf5ec64537c3ee024bc726ee723c01 (patch)
tree830fda3221eb1207bb837f78298032be2d2c1706 /libc/stdio/stdio.cpp
parentd8244214751f9b48e60e69910c4e7175f8fab1ac (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/stdio/stdio.cpp')
-rw-r--r--libc/stdio/stdio.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index b709b40c8..b0f5c607f 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -848,3 +848,16 @@ int wprintf(const wchar_t* fmt, ...) {
int wscanf(const wchar_t* fmt, ...) {
PRINTF_IMPL(vfwscanf(stdin, fmt, ap));
}
+
+namespace {
+
+namespace phony {
+#include <bits/struct_file.h>
+}
+
+static_assert(sizeof(::__sFILE) == sizeof(phony::__sFILE),
+ "size mismatch between `struct __sFILE` implementation and public stub");
+static_assert(alignof(::__sFILE) == alignof(phony::__sFILE),
+ "alignment mismatch between `struct __sFILE` implementation and public stub");
+
+}