py/mpconfig.h: Add MICROPY_STREAMS_POSIX_API setting.

To filter out even prototypes of mp_stream_posix_*() functions, which
require POSIX types like ssize_t & off_t, which may be not available in
some ports.
pull/2245/merge
Paul Sokolovsky 2016-07-30 20:05:56 +03:00
rodzic 58d9d85a56
commit 61e77a4e88
5 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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)

Wyświetl plik

@ -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

Wyświetl plik

@ -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)

Wyświetl plik

@ -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)