diff --git a/rldefs.h b/rldefs.h
index 0257754..099420c 100644
--- a/rldefs.h
+++ b/rldefs.h
@@ -34,6 +34,14 @@
 #  undef HAVE_STRCOLL
 #endif
 
+#if defined (__native_client__) && !defined (_POSIX_VERSION)
+/* Currently the newlib toolchain in NaCl doesn't define _POSIX_VERSION
+ * which causes readline to fall back to using ioctl() rather than
+ * tcgetattr().  TODO(sbc): remove this patch once either ioctl() is
+ * supported on tty nodes or _POSIX_VERSION is defined by newlib headers. */
+#define _POSIX_VERSION 199309L
+#endif
+
 #if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
 #  define TERMIOS_TTY_DRIVER
 #else

diff --git a/rldefs.h b/rldefs.h
index 0257754..991f308 100644
--- a/rldefs.h
+++ b/rldefs.h
@@ -34,6 +34,22 @@
 #  undef HAVE_STRCOLL
 #endif
 
+#if defined (__native_client__) && !defined (_POSIX_VERSION)
+/* Currently the newlib toolchain in NaCl doesn't define _POSIX_VERSION
+ * which causes readline to fall back to using ioctl() rather than
+ * tcgetattr().  TODO(sbc): remove this patch once either ioctl() is
+ * supported on tty nodes or _POSIX_VERSION is defined by newlib headers. */
+#define _POSIX_VERSION 199309L
+#endif
+
+#if defined (__native_client__) && !defined (__GLIBC__) && !defined TCOON
+// TODO(sbc): remove once these are added to termios.h in NaCl
+#define TCOOFF    0
+#define TCOON     1
+#define TCIOFF    2
+#define TCION     3
+#endif
+
 #if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
 #  define TERMIOS_TTY_DRIVER
 #else

Fix newlib build of readline.
Fix newlib build of readline.

R=binji@chromium.org

Review URL: https://codereview.chromium.org/22986023

git-svn-id: 84b3587ce119b778414dcb50e18b7479aacf4f1d@874 7dad1e8b-422e-d2af-fbf5-8013b78bd812
