diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h
index 299dc8eaea3cd9ff26684f7f8180d38e20318e81..0cd7e8c313cb79cbf8048db8b7305547df75fca4 100644
--- a/esp8266/mpconfigport.h
+++ b/esp8266/mpconfigport.h
@@ -75,6 +75,7 @@
 #define MICROPY_WARNINGS            (1)
 #define MICROPY_PY_STR_BYTES_CMP_WARN (1)
 #define MICROPY_STREAMS_NON_BLOCK   (1)
+#define MICROPY_STREAMS_POSIX_API   (1)
 #define MICROPY_MODULE_FROZEN_STR   (1)
 #define MICROPY_MODULE_FROZEN_MPY   (1)
 #define MICROPY_MODULE_FROZEN_LEXER mp_lexer_new_from_str32
diff --git a/py/mpconfig.h b/py/mpconfig.h
index edf6e71d0ef092f160aa1824f00608c9177de172..890e072ab52bc508e60765fa2e20d434cad7f635 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -522,6 +522,12 @@ typedef double mp_float_t;
 #define MICROPY_STREAMS_NON_BLOCK (0)
 #endif
 
+// Whether to provide stream functions with POSIX-like signatures
+// (useful for porting existing libraries to MicroPython).
+#ifndef MICROPY_STREAMS_POSIX_API
+#define MICROPY_STREAMS_POSIX_API (0)
+#endif
+
 // Whether to call __init__ when importing builtin modules for the first time
 #ifndef MICROPY_MODULE_BUILTIN_INIT
 #define MICROPY_MODULE_BUILTIN_INIT (0)
diff --git a/py/stream.c b/py/stream.c
index d426973e835058949f259448fd9bf1e77ab01429..473eb9690480ae015a3c10c5e4d0368513027d08 100644
--- a/py/stream.c
+++ b/py/stream.c
@@ -511,6 +511,7 @@ STATIC mp_obj_t stream_ioctl(size_t n_args, const mp_obj_t *args) {
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_ioctl_obj, 2, 3, stream_ioctl);
 
+#if MICROPY_STREAMS_POSIX_API
 /*
  * POSIX-like functions
  *
@@ -519,7 +520,6 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_ioctl_obj, 2, 3, stream_ioctl);
  * POSIX-compatible software to work with MicroPython streams.
  */
 
-
 // errno-like variable. If any of the functions below returned with error
 // status, this variable will contain error no.
 int mp_stream_errno;
@@ -568,3 +568,5 @@ int mp_stream_posix_fsync(mp_obj_t stream) {
     }
     return res;
 }
+
+#endif
diff --git a/py/stream.h b/py/stream.h
index 8dd6898873d22f29e089e68798053c396343be2a..33d85e823c901a967e1a6ebb5b82a26b523a745a 100644
--- a/py/stream.h
+++ b/py/stream.h
@@ -84,11 +84,13 @@ mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode,
 
 void mp_stream_write_adaptor(void *self, const char *buf, size_t len);
 
+#if MICROPY_STREAMS_POSIX_API
 // Functions with POSIX-compatible signatures
 ssize_t mp_stream_posix_write(mp_obj_t stream, const void *buf, size_t len);
 ssize_t mp_stream_posix_read(mp_obj_t stream, void *buf, size_t len);
 off_t mp_stream_posix_lseek(mp_obj_t stream, off_t offset, int whence);
 int mp_stream_posix_fsync(mp_obj_t stream);
+#endif
 
 #if MICROPY_STREAMS_NON_BLOCK
 #define mp_is_nonblocking_error(errno) ((errno) == EAGAIN || (errno) == EWOULDBLOCK)
diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index 2f4ec1121183adbde8c6b49b7aa141fbc6a19827..58061b28acd5b30245ec7282d1dd8bbcad315a89 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -63,6 +63,7 @@
 #define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_DOUBLE)
 #define MICROPY_LONGINT_IMPL        (MICROPY_LONGINT_IMPL_MPZ)
 #define MICROPY_STREAMS_NON_BLOCK   (1)
+#define MICROPY_STREAMS_POSIX_API   (1)
 #define MICROPY_OPT_COMPUTED_GOTO   (1)
 #ifndef MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE
 #define MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE (1)