aboutsummaryrefslogtreecommitdiff
path: root/py/stream.h
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-10-18 15:37:19 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-10-18 15:39:33 +0300
commit779941095064efa0be8eca339f866311e19d9c0d (patch)
treeff370ed54d34705b04a3c656e3647c29f6ef6622 /py/stream.h
parent2ca7b05552bb75540bd282ba5bb937769ecb69ce (diff)
py/stream: Allow to reuse is_nonblocking_error().
Diffstat (limited to 'py/stream.h')
-rw-r--r--py/stream.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/py/stream.h b/py/stream.h
index f9ba3387a..5eace916f 100644
--- a/py/stream.h
+++ b/py/stream.h
@@ -42,4 +42,12 @@ mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self);
mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, mp_uint_t len);
+#if MICROPY_STREAMS_NON_BLOCK
+// TODO: This is POSIX-specific (but then POSIX is the only real thing,
+// and anything else just emulates it, right?)
+#define mp_is_nonblocking_error(errno) ((errno) == EAGAIN || (errno) == EWOULDBLOCK)
+#else
+#define mp_is_nonblocking_error(errno) (0)
+#endif
+
#endif // __MICROPY_INCLUDED_PY_STREAM_H__