File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -249,6 +249,11 @@ typedef double mp_float_t;
249249#define MICROPY_PATH_MAX (512)
250250#endif
251251
252+ // Whether POSIX-semantics non-blocking streams are supported
253+ #ifndef MICROPY_STREAMS_NON_BLOCK
254+ #define MICROPY_STREAMS_NON_BLOCK (0)
255+ #endif
256+
252257// Whether to use computed gotos in the VM, or a switch
253258// Computed gotos are roughly 10% faster, and increase VM code size by a little
254259#ifndef MICROPY_USE_COMPUTED_GOTO
Original file line number Diff line number Diff line change 2525 */
2626
2727#include <string.h>
28- #include <errno.h>
2928
3029#include "mpconfig.h"
3130#include "nlr.h"
3231#include "misc.h"
3332#include "qstr.h"
3433#include "obj.h"
3534#include "stream.h"
35+ #if MICROPY_STREAMS_NON_BLOCK
36+ #include <errno.h>
37+ #endif
3638
3739// This file defines generic Python stream read/write methods which
3840// dispatch to the underlying stream interface of an object.
4244
4345STATIC mp_obj_t stream_readall (mp_obj_t self_in );
4446
47+ #if MICROPY_STREAMS_NON_BLOCK
4548// TODO: This is POSIX-specific (but then POSIX is the only real thing,
4649// and anything else just emulates it, right?)
4750#define is_nonblocking_error (errno ) ((errno) == EAGAIN || (errno) == EWOULDBLOCK)
51+ #else
52+ #define is_nonblocking_error (errno ) (0)
53+ #endif
4854
4955STATIC mp_obj_t stream_read (uint n_args , const mp_obj_t * args ) {
5056 struct _mp_obj_base_t * o = (struct _mp_obj_base_t * )args [0 ];
Original file line number Diff line number Diff line change 3939#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE)
4040#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ)
4141#define MICROPY_PATH_MAX (PATH_MAX)
42+ #define MICROPY_STREAMS_NON_BLOCK (1)
4243#define MICROPY_USE_COMPUTED_GOTO (1)
4344#define MICROPY_MOD_SYS_STDFILES (1)
4445#define MICROPY_ENABLE_MOD_CMATH (1)
You can’t perform that action at this time.
0 commit comments