Merge stdio/local.h and stdio/wcio.h.
Bug: N/A
Test: ran tests
Change-Id: I683a1c45db0b880c73f8d190a46deeeab4cfef6e
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index 11b136d..d04abc1 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -42,8 +42,6 @@
#include "private/bionic_fortify.h"
#endif
-#include "wcio.h"
-
/*
* Information local to this implementation of stdio,
* in particular, macros and private variables.
@@ -110,6 +108,19 @@
// below, and accessed via `_EXT`.
};
+/* minimal requirement of SUSv2 */
+#define WCIO_UNGETWC_BUFSIZE 1
+
+struct wchar_io_data {
+ mbstate_t wcio_mbstate_in;
+ mbstate_t wcio_mbstate_out;
+
+ wchar_t wcio_ungetwc_buf[WCIO_UNGETWC_BUFSIZE];
+ size_t wcio_ungetwc_inbuf;
+
+ int wcio_mode; /* orientation */
+};
+
struct __sfileext {
// ungetc buffer.
struct __sbuf _ub;
@@ -276,4 +287,23 @@
char* __hldtoa(long double, const char*, int, int*, int*, char**);
char* __ldtoa(long double*, int, int, int*, int*, char**);
+#define WCIO_GET(fp) \
+ (_EXT(fp) ? &(_EXT(fp)->_wcio) : (struct wchar_io_data *)0)
+
+#define _SET_ORIENTATION(fp, mode) \
+do {\
+ struct wchar_io_data *_wcio = WCIO_GET(fp); \
+ if (_wcio && _wcio->wcio_mode == 0) \
+ _wcio->wcio_mode = (mode);\
+} while (0)
+
+#define WCIO_FREE(fp) \
+do {\
+ struct wchar_io_data *_wcio = WCIO_GET(fp); \
+ if (_wcio) { \
+ _wcio->wcio_mode = 0;\
+ _wcio->wcio_ungetwc_inbuf = 0;\
+ } \
+} while (0)
+
__END_DECLS