diff --git a/extmod/vfs_posix.c b/extmod/vfs_posix.c index 3694ebaf9..06a04eff0 100644 --- a/extmod/vfs_posix.c +++ b/extmod/vfs_posix.c @@ -41,6 +41,7 @@ #include #include #include +#include #ifdef _MSC_VER #include // For mkdir etc. #endif diff --git a/extmod/vfs_posix_file.c b/extmod/vfs_posix_file.c index ea19de7fd..2453612ed 100644 --- a/extmod/vfs_posix_file.c +++ b/extmod/vfs_posix_file.c @@ -35,7 +35,7 @@ #include #include -#ifdef _WIN32 +#if defined(_WIN32) || defined(__sh__) #define fsync _commit #else #include diff --git a/ports/sh/main.c b/ports/sh/main.c index 84ec07986..28610e09f 100644 --- a/ports/sh/main.c +++ b/ports/sh/main.c @@ -124,34 +124,3 @@ void gc_collect(void) { gc_helper_collect_regs_and_stack(); gc_collect_end(); } - -// There is no filesystem so stat'ing returns nothing. -mp_import_stat_t mp_import_stat(const char *path) -{ - struct stat st; - int rc = stat(path, &st); - if(rc < 0) - return MP_IMPORT_STAT_NO_EXIST; - - if(S_ISDIR(st.st_mode)) - return MP_IMPORT_STAT_DIR; - else - return MP_IMPORT_STAT_FILE; -} - -mp_obj_t mp_builtin_open(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) -{ - mp_obj_t *args_items; - size_t len; - mp_obj_get_array(*args, &len, &args_items); - printf("%d %p\n", (int)len, args_items); - if(len != 2) - return mp_const_none; - - char const *path = mp_obj_str_get_str(args_items[0]); - char const *mode = mp_obj_str_get_str(args_items[1]); - printf("'%s' '%s'\n", path, mode); - - return mp_const_none; -} -MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_open_obj, 1, mp_builtin_open); diff --git a/ports/sh/mpconfigport.h b/ports/sh/mpconfigport.h index bddb2e9a2..277b5c7bc 100644 --- a/ports/sh/mpconfigport.h +++ b/ports/sh/mpconfigport.h @@ -11,6 +11,8 @@ #define MICROPY_GC_SPLIT_HEAP (1) #define MP_ENDIANNESS_BIG (1) #define MICROPY_READER_POSIX (1) +#define MICROPY_VFS (1) +#define MICROPY_VFS_POSIX (1) #define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) #define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) #define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) @@ -21,6 +23,7 @@ #define MICROPY_ENABLE_SOURCE_LINE (1) /* in EXTRA_FEATURES */ #define MICROPY_PY_BUILTINS_STR_UNICODE (1) /* in EXTRA_FEATURES */ #define MICROPY_PY_BUILTINS_HELP_MODULES (1) /* in EXTRA_FEATURES */ +#define MICROPY_ENABLE_FINALISER (1) /* in EXTRA_FEATURES */ // #define MICROPY_PY_SYS_STDFILES (1) /* in EXTRA_FEATURES */ #define MICROPY_ALLOC_PATH_MAX (256) diff --git a/ports/sh/mphalport.h b/ports/sh/mphalport.h index 0db02a8c2..9d8f5b3d0 100644 --- a/ports/sh/mphalport.h +++ b/ports/sh/mphalport.h @@ -1 +1,10 @@ static inline void mp_hal_set_interrupt_char(char c) {} + +/* We don't need to provide retries since gint doesn't have EINTR */ +#define MP_HAL_RETRY_SYSCALL(ret, syscall, raise) { \ + ret = syscall; \ + if(ret == -1) { \ + int err = errno; \ + raise; \ + } \ +}