From b82f34edde79e14d6b9260b3fddaf36b1354a558 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 13 Jul 2014 13:49:51 +0300 Subject: unix: Allow to disable MICROPY_EMIT_X64 from commandline. emitnative in particular requires nlr_* to be real functions, so doesn't compile with MICROPY_NLR_SETJMP=1. --- unix/mpconfigport.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'unix') diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h index 73435863b7..0831e3fd34 100644 --- a/unix/mpconfigport.h +++ b/unix/mpconfigport.h @@ -27,7 +27,9 @@ // options to control how Micro Python is built #define MICROPY_ALLOC_PATH_MAX (PATH_MAX) +#ifndef MICROPY_EMIT_X64 #define MICROPY_EMIT_X64 (1) +#endif #define MICROPY_EMIT_THUMB (0) #define MICROPY_EMIT_INLINE_THUMB (0) #define MICROPY_ENABLE_GC (1) -- cgit v1.2.3 From 122c9db3dbbb6286c81d59cc979799d34974cae0 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 13 Jul 2014 23:05:24 +0300 Subject: unix: file: Implement .flush() method. This method apparently should be part of stream interface. --- unix/file.c | 8 ++++++++ unix/qstrdefsport.h | 1 + 2 files changed, 9 insertions(+) (limited to 'unix') diff --git a/unix/file.c b/unix/file.c index 62e3253b7d..433decfc33 100644 --- a/unix/file.c +++ b/unix/file.c @@ -82,6 +82,13 @@ STATIC mp_int_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int return r; } +STATIC mp_obj_t fdfile_flush(mp_obj_t self_in) { + mp_obj_fdfile_t *self = self_in; + fsync(self->fd); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(fdfile_flush_obj, fdfile_flush); + STATIC mp_obj_t fdfile_close(mp_obj_t self_in) { mp_obj_fdfile_t *self = self_in; close(self->fd); @@ -166,6 +173,7 @@ STATIC const mp_map_elem_t rawfile_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_readline), (mp_obj_t)&mp_stream_unbuffered_readline_obj}, { MP_OBJ_NEW_QSTR(MP_QSTR_readlines), (mp_obj_t)&mp_stream_unbuffered_readlines_obj}, { MP_OBJ_NEW_QSTR(MP_QSTR_write), (mp_obj_t)&mp_stream_write_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_flush), (mp_obj_t)&fdfile_flush_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_close), (mp_obj_t)&fdfile_close_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR___enter__), (mp_obj_t)&mp_identity_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR___exit__), (mp_obj_t)&fdfile___exit___obj }, diff --git a/unix/qstrdefsport.h b/unix/qstrdefsport.h index de0b3d8fae..05c9180177 100644 --- a/unix/qstrdefsport.h +++ b/unix/qstrdefsport.h @@ -32,6 +32,7 @@ Q(fileno) Q(makefile) Q(FileIO) +Q(flush) Q(_os) Q(stat) -- cgit v1.2.3 From dce8876dbe272d34d8d28aac21b4a4c3bdea0317 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 13 Jul 2014 23:24:08 +0300 Subject: unix: file: No fsync() on Windows. --- unix/file.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'unix') diff --git a/unix/file.c b/unix/file.c index 433decfc33..056a7b6e84 100644 --- a/unix/file.c +++ b/unix/file.c @@ -83,8 +83,12 @@ STATIC mp_int_t fdfile_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int } STATIC mp_obj_t fdfile_flush(mp_obj_t self_in) { +#ifndef _WIN32 mp_obj_fdfile_t *self = self_in; fsync(self->fd); +#else + //TODO +#endif return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_1(fdfile_flush_obj, fdfile_flush); -- cgit v1.2.3