summaryrefslogtreecommitdiffstatshomepage
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/Makefile56
-rw-r--r--unix/alloc.c2
-rw-r--r--unix/coverage.c3
-rw-r--r--unix/fdfile.h9
-rw-r--r--unix/file.c4
-rw-r--r--unix/gccollect.c2
-rw-r--r--unix/input.c2
-rw-r--r--unix/input.h5
-rw-r--r--unix/main.c2
-rw-r--r--unix/modffi.c12
-rw-r--r--unix/modjni.c40
-rw-r--r--unix/modmachine.c2
-rw-r--r--unix/modos.c4
-rw-r--r--unix/modsocket.c9
-rw-r--r--unix/modtermios.c2
-rw-r--r--unix/modtime.c41
-rw-r--r--unix/moduselect.c2
-rw-r--r--unix/mpconfigport.h4
-rw-r--r--unix/mpconfigport.mk10
-rw-r--r--unix/mpconfigport_coverage.h1
-rw-r--r--unix/mpconfigport_fast.h2
-rw-r--r--unix/mpconfigport_minimal.h6
-rw-r--r--unix/mphalport.h2
-rw-r--r--unix/mpthreadport.h4
-rw-r--r--unix/qstrdefsport.h2
-rw-r--r--unix/unix_mphal.c2
26 files changed, 127 insertions, 103 deletions
diff --git a/unix/Makefile b/unix/Makefile
index be324dd3dd..08bd4db306 100644
--- a/unix/Makefile
+++ b/unix/Makefile
@@ -14,10 +14,10 @@ QSTR_DEFS = qstrdefsport.h
UNAME_S := $(shell uname -s)
# include py core make definitions
-include ../py/py.mk
+include $(TOP)/py/py.mk
INC += -I.
-INC += -I..
+INC += -I$(TOP)
INC += -I$(BUILD)
# compiler settings
@@ -30,7 +30,7 @@ ifdef DEBUG
CFLAGS += -g
COPT = -O0
else
-COPT = -Os -fdata-sections -ffunction-sections #-DNDEBUG
+COPT = -Os -fdata-sections -ffunction-sections -DNDEBUG
# _FORTIFY_SOURCE is a feature in gcc/glibc which is intended to provide extra
# security for detecting buffer overflows. Some distros (Ubuntu at the very least)
# have it enabled by default.
@@ -59,7 +59,7 @@ CFLAGS += -U _FORTIFY_SOURCE
endif
# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed.
-# The unix port of micropython on OSX must be compiled with clang,
+# The unix port of MicroPython on OSX must be compiled with clang,
# while cross-compile ports require gcc, so we test here for OSX and
# if necessary override the value of 'CC' set in py/mkenv.mk
ifeq ($(UNAME_S),Darwin)
@@ -87,7 +87,7 @@ endif
endif
ifeq ($(MICROPY_USE_READLINE),1)
-INC += -I../lib/mp-readline
+INC += -I$(TOP)/lib/mp-readline
CFLAGS_MOD += -DMICROPY_USE_READLINE=1
LIB_SRC_C_EXTRA += mp-readline/readline.c
endif
@@ -107,11 +107,11 @@ endif
ifeq ($(MICROPY_PY_FFI),1)
ifeq ($(MICROPY_STANDALONE),1)
-LIBFFI_CFLAGS_MOD := -I$(shell ls -1d ../lib/libffi/build_dir/out/lib/libffi-*/include)
+LIBFFI_CFLAGS_MOD := -I$(shell ls -1d $(TOP)/lib/libffi/build_dir/out/lib/libffi-*/include)
ifeq ($(MICROPY_FORCE_32BIT),1)
- LIBFFI_LDFLAGS_MOD = ../lib/libffi/build_dir/out/lib32/libffi.a
+ LIBFFI_LDFLAGS_MOD = $(TOP)/lib/libffi/build_dir/out/lib32/libffi.a
else
- LIBFFI_LDFLAGS_MOD = ../lib/libffi/build_dir/out/lib/libffi.a
+ LIBFFI_LDFLAGS_MOD = $(TOP)/lib/libffi/build_dir/out/lib/libffi.a
endif
else
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
@@ -183,13 +183,13 @@ MPY_CROSS_FLAGS += -mcache-lookup-bc
endif
-include ../py/mkrules.mk
+include $(TOP)/py/mkrules.mk
.PHONY: test
-test: $(PROG) ../tests/run-tests
+test: $(PROG) $(TOP)/tests/run-tests
$(eval DIRNAME=$(notdir $(CURDIR)))
- cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests
# install micropython in /usr/local/bin
TARGET = micropython
@@ -254,12 +254,12 @@ coverage:
coverage_test: coverage
$(eval DIRNAME=$(notdir $(CURDIR)))
- cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests
- cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests -d thread
- cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --emit native
- cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --via-mpy -d basics float
- gcov -o build-coverage/py ../py/*.c
- gcov -o build-coverage/extmod ../extmod/*.c
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests -d thread
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --emit native
+ cd $(TOP)/tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --via-mpy -d basics float
+ gcov -o build-coverage/py $(TOP)/py/*.c
+ gcov -o build-coverage/extmod $(TOP)/extmod/*.c
# Value of configure's --host= option (required for cross-compilation).
# Deduce it from CROSS_COMPILE by default, but can be overridden.
@@ -274,21 +274,21 @@ deplibs: libffi axtls
# install-exec-recursive & install-data-am targets are used to avoid building
# docs and depending on makeinfo
libffi:
- cd ../lib/libffi; git clean -d -x -f
- cd ../lib/libffi; ./autogen.sh
- mkdir -p ../lib/libffi/build_dir; cd ../lib/libffi/build_dir; \
+ cd $(TOP)/lib/libffi; git clean -d -x -f
+ cd $(TOP)/lib/libffi; ./autogen.sh
+ mkdir -p $(TOP)/lib/libffi/build_dir; cd $(TOP)/lib/libffi/build_dir; \
../configure $(CROSS_COMPILE_HOST) --prefix=$$PWD/out --disable-structs CC="$(CC)" CXX="$(CXX)" LD="$(LD)" CFLAGS="-Os -fomit-frame-pointer -fstrict-aliasing -ffast-math -fno-exceptions"; \
$(MAKE) install-exec-recursive; $(MAKE) -C include install-data-am
axtls: $(BUILD)/libaxtls.a
-$(BUILD)/libaxtls.a: ../lib/axtls/README | $(OBJ_DIRS)
- cd ../lib/axtls; cp config/upyconfig config/.config
- cd ../lib/axtls; $(MAKE) oldconfig -B
- cd ../lib/axtls; $(MAKE) clean
- cd ../lib/axtls; $(MAKE) all CC="$(CC)" LD="$(LD)"
- cp ../lib/axtls/_stage/libaxtls.a $@
+$(BUILD)/libaxtls.a: $(TOP)/lib/axtls/README | $(OBJ_DIRS)
+ cd $(TOP)/lib/axtls; cp config/upyconfig config/.config
+ cd $(TOP)/lib/axtls; $(MAKE) oldconfig -B
+ cd $(TOP)/lib/axtls; $(MAKE) clean
+ cd $(TOP)/lib/axtls; $(MAKE) all CC="$(CC)" LD="$(LD)"
+ cp $(TOP)/lib/axtls/_stage/libaxtls.a $@
-../lib/axtls/README:
+$(TOP)/lib/axtls/README:
@echo "You cloned without --recursive, fetching submodules for you."
- (cd ..; git submodule update --init --recursive)
+ (cd $(TOP); git submodule update --init --recursive)
diff --git a/unix/alloc.c b/unix/alloc.c
index 54fc1d3c4a..ca12d025b6 100644
--- a/unix/alloc.c
+++ b/unix/alloc.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
diff --git a/unix/coverage.c b/unix/coverage.c
index 09959525a0..4a9ab194bb 100644
--- a/unix/coverage.c
+++ b/unix/coverage.c
@@ -154,6 +154,7 @@ STATIC mp_obj_t extra_coverage(void) {
mp_printf(&mp_plat_print, "%u\n", 0x80000000); // should print unsigned
mp_printf(&mp_plat_print, "%x\n", 0x80000000); // should print unsigned
mp_printf(&mp_plat_print, "%X\n", 0x80000000); // should print unsigned
+ mp_printf(&mp_plat_print, "abc\n%"); // string ends in middle of format specifier
}
// vstr
@@ -189,7 +190,7 @@ STATIC mp_obj_t extra_coverage(void) {
mp_printf(&mp_plat_print, "# repl\n");
const char *str;
- mp_uint_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str);
+ size_t len = mp_repl_autocomplete("__n", 3, &mp_plat_print, &str);
mp_printf(&mp_plat_print, "%.*s\n", (int)len, str);
mp_store_global(MP_QSTR_sys, mp_import_name(MP_QSTR_sys, mp_const_none, MP_OBJ_NEW_SMALL_INT(0)));
diff --git a/unix/fdfile.h b/unix/fdfile.h
index 8e8e97c795..69a9b6be41 100644
--- a/unix/fdfile.h
+++ b/unix/fdfile.h
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@@ -24,12 +24,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+#ifndef MICROPY_INCLUDED_UNIX_FDFILE_H
+#define MICROPY_INCLUDED_UNIX_FDFILE_H
#include "py/obj.h"
-#ifndef __MICROPY_INCLUDED_UNIX_FILE_H__
-#define __MICROPY_INCLUDED_UNIX_FILE_H__
-
typedef struct _mp_obj_fdfile_t {
mp_obj_base_t base;
int fd;
@@ -38,4 +37,4 @@ typedef struct _mp_obj_fdfile_t {
extern const mp_obj_type_t mp_type_fileio;
extern const mp_obj_type_t mp_type_textio;
-#endif // __MICROPY_INCLUDED_UNIX_FILE_H__
+#endif // MICROPY_INCLUDED_UNIX_FDFILE_H
diff --git a/unix/file.c b/unix/file.c
index a60840c813..0d65f9ca0d 100644
--- a/unix/file.c
+++ b/unix/file.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@@ -47,7 +47,7 @@
#ifdef MICROPY_CPYTHON_COMPAT
STATIC void check_fd_is_open(const mp_obj_fdfile_t *o) {
if (o->fd < 0) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "I/O operation on closed file"));
+ mp_raise_ValueError("I/O operation on closed file");
}
}
#else
diff --git a/unix/gccollect.c b/unix/gccollect.c
index 4ec8c2bf54..02f6fc91a8 100644
--- a/unix/gccollect.c
+++ b/unix/gccollect.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
diff --git a/unix/input.c b/unix/input.c
index 4b10350dfc..7d60b46cc7 100644
--- a/unix/input.c
+++ b/unix/input.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
diff --git a/unix/input.h b/unix/input.h
index 7cbee33c5d..a76b87e644 100644
--- a/unix/input.h
+++ b/unix/input.h
@@ -1,3 +1,8 @@
+#ifndef MICROPY_INCLUDED_UNIX_INPUT_H
+#define MICROPY_INCLUDED_UNIX_INPUT_H
+
char *prompt(char *p);
void prompt_read_history(void);
void prompt_write_history(void);
+
+#endif // MICROPY_INCLUDED_UNIX_INPUT_H
diff --git a/unix/main.c b/unix/main.c
index 633144c863..e861d7f112 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
diff --git a/unix/modffi.c b/unix/modffi.c
index 7a35d61ef4..9b514371bc 100644
--- a/unix/modffi.c
+++ b/unix/modffi.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@@ -134,7 +134,7 @@ STATIC ffi_type *get_ffi_type(mp_obj_t o_in)
}
// TODO: Support actual libffi type objects
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "Unknown type"));
+ mp_raise_TypeError("Unknown type");
}
STATIC mp_obj_t return_ffi_value(ffi_arg val, char type)
@@ -203,7 +203,7 @@ STATIC mp_obj_t make_func(mp_obj_t rettype_in, void *func, mp_obj_t argtypes_in)
int res = ffi_prep_cif(&o->cif, FFI_DEFAULT_ABI, nparams, char2ffi_type(*rettype), o->params);
if (res != FFI_OK) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Error in ffi_prep_cif"));
+ mp_raise_ValueError("Error in ffi_prep_cif");
}
return MP_OBJ_FROM_PTR(o);
@@ -261,12 +261,12 @@ STATIC mp_obj_t mod_ffi_callback(mp_obj_t rettype_in, mp_obj_t func_in, mp_obj_t
int res = ffi_prep_cif(&o->cif, FFI_DEFAULT_ABI, nparams, char2ffi_type(*rettype), o->params);
if (res != FFI_OK) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Error in ffi_prep_cif"));
+ mp_raise_ValueError("Error in ffi_prep_cif");
}
res = ffi_prep_closure_loc(o->clo, &o->cif, call_py_func, MP_OBJ_TO_PTR(func_in), o->func);
if (res != FFI_OK) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "ffi_prep_closure_loc"));
+ mp_raise_ValueError("ffi_prep_closure_loc");
}
return MP_OBJ_FROM_PTR(o);
@@ -409,7 +409,7 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
}
error:
- nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "Don't know how to pass object to native function"));
+ mp_raise_TypeError("Don't know how to pass object to native function");
}
STATIC const mp_obj_type_t ffifunc_type = {
diff --git a/unix/modjni.c b/unix/modjni.c
index b474e26ea7..df9cd9d67a 100644
--- a/unix/modjni.c
+++ b/unix/modjni.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@@ -159,7 +159,7 @@ STATIC void jclass_attr(mp_obj_t self_in, qstr attr_in, mp_obj_t *dest) {
STATIC mp_obj_t jclass_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
if (n_kw != 0) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "kwargs not supported"));
+ mp_raise_TypeError("kwargs not supported");
}
mp_obj_jclass_t *self = self_in;
@@ -168,9 +168,9 @@ STATIC mp_obj_t jclass_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
return call_method(self->cls, NULL, methods, true, n_args, args);
}
-STATIC const mp_map_elem_t jclass_locals_dict_table[] = {
-// { MP_OBJ_NEW_QSTR(MP_QSTR_get), (mp_obj_t)&ffivar_get_obj },
-// { MP_OBJ_NEW_QSTR(MP_QSTR_set), (mp_obj_t)&ffivar_set_obj },
+STATIC const mp_rom_map_elem_t jclass_locals_dict_table[] = {
+// { MP_ROM_QSTR(MP_QSTR_get), MP_ROM_PTR(&ffivar_get_obj) },
+// { MP_ROM_QSTR(MP_QSTR_set), MP_ROM_PTR(&ffivar_set_obj) },
};
STATIC MP_DEFINE_CONST_DICT(jclass_locals_dict, jclass_locals_dict_table);
@@ -181,7 +181,7 @@ STATIC const mp_obj_type_t jclass_type = {
.print = jclass_print,
.attr = jclass_attr,
.call = jclass_call,
- .locals_dict = (mp_obj_t)&jclass_locals_dict,
+ .locals_dict = (mp_obj_dict_t*)&jclass_locals_dict,
};
STATIC mp_obj_t new_jclass(jclass jc) {
@@ -268,7 +268,7 @@ STATIC mp_obj_t jobject_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value)
return mp_const_none;
}
}
- mp_not_implemented("");
+ mp_raise_NotImplementedError("");
}
if (!JJ(IsInstanceOf, self->obj, List_class)) {
@@ -331,7 +331,7 @@ STATIC const mp_obj_type_t jobject_type = {
.attr = jobject_attr,
.subscr = jobject_subscr,
.getiter = subscr_getiter,
-// .locals_dict = (mp_obj_t)&jobject_locals_dict,
+// .locals_dict = (mp_obj_dict_t*)&jobject_locals_dict,
};
STATIC mp_obj_t new_jobject(jobject jo) {
@@ -433,7 +433,7 @@ STATIC bool py2jvalue(const char **jtypesig, mp_obj_t arg, jvalue *out) {
}
out->l = NULL;
} else {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "arg type not supported"));
+ mp_raise_TypeError("arg type not supported");
}
*jtypesig = arg_type;
@@ -534,7 +534,7 @@ STATIC mp_obj_t call_method(jobject obj, const char *name, jarray methods, bool
ret = new_jobject(res);
} else {
JJ(ReleaseStringUTFChars, name_o, decl);
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "cannot handle return type"));
+ mp_raise_TypeError("cannot handle return type");
}
JJ(ReleaseStringUTFChars, name_o, decl);
@@ -550,13 +550,13 @@ next_method:
JJ(DeleteLocalRef, meth);
}
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "method not found"));
+ mp_raise_TypeError("method not found");
}
STATIC mp_obj_t jmethod_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
if (n_kw != 0) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "kwargs not supported"));
+ mp_raise_TypeError("kwargs not supported");
}
mp_obj_jmethod_t *self = self_in;
@@ -578,7 +578,7 @@ STATIC const mp_obj_type_t jmethod_type = {
.print = jmethod_print,
.call = jmethod_call,
// .attr = jobject_attr,
-// .locals_dict = (mp_obj_t)&jobject_locals_dict,
+// .locals_dict = (mp_obj_dict_t*)&jobject_locals_dict,
};
#ifdef __ANDROID__
@@ -602,13 +602,13 @@ STATIC void create_jvm() {
void *libjvm = dlopen(LIBJVM_SO, RTLD_NOW | RTLD_GLOBAL);
if (!libjvm) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "unable to load libjvm.so, use LD_LIBRARY_PATH"));
+ mp_raise_msg(&mp_type_OSError, "unable to load libjvm.so, use LD_LIBRARY_PATH");
}
int (*_JNI_CreateJavaVM)(void*, void**, void*) = dlsym(libjvm, "JNI_CreateJavaVM");
int st = _JNI_CreateJavaVM(&jvm, (void**)&env, &args);
if (st < 0 || !env) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "unable to create JVM"));
+ mp_raise_msg(&mp_type_OSError, "unable to create JVM");
}
Class_class = JJ(FindClass, "java/lang/Class");
@@ -707,11 +707,11 @@ STATIC mp_obj_t mod_jni_env() {
}
MP_DEFINE_CONST_FUN_OBJ_0(mod_jni_env_obj, mod_jni_env);
-STATIC const mp_map_elem_t mp_module_jni_globals_table[] = {
- { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_jni) },
- { MP_OBJ_NEW_QSTR(MP_QSTR_cls), (mp_obj_t)&mod_jni_cls_obj },
- { MP_OBJ_NEW_QSTR(MP_QSTR_array), (mp_obj_t)&mod_jni_array_obj },
- { MP_OBJ_NEW_QSTR(MP_QSTR_env), (mp_obj_t)&mod_jni_env_obj },
+STATIC const mp_rom_map_elem_t mp_module_jni_globals_table[] = {
+ { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_jni) },
+ { MP_ROM_QSTR(MP_QSTR_cls), MP_ROM_PTR(&mod_jni_cls_obj) },
+ { MP_ROM_QSTR(MP_QSTR_array), MP_ROM_PTR(&mod_jni_array_obj) },
+ { MP_ROM_QSTR(MP_QSTR_env), MP_ROM_PTR(&mod_jni_env_obj) },
};
STATIC MP_DEFINE_CONST_DICT(mp_module_jni_globals, mp_module_jni_globals_table);
diff --git a/unix/modmachine.c b/unix/modmachine.c
index 33a3b098e4..48dddec0ae 100644
--- a/unix/modmachine.c
+++ b/unix/modmachine.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
diff --git a/unix/modos.c b/unix/modos.c
index 8e746c1637..5030fbb65b 100644
--- a/unix/modos.c
+++ b/unix/modos.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@@ -58,7 +58,7 @@ STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) {
t->items[3] = MP_OBJ_NEW_SMALL_INT(sb.st_nlink);
t->items[4] = MP_OBJ_NEW_SMALL_INT(sb.st_uid);
t->items[5] = MP_OBJ_NEW_SMALL_INT(sb.st_gid);
- t->items[6] = MP_OBJ_NEW_SMALL_INT(sb.st_size);
+ t->items[6] = mp_obj_new_int_from_uint(sb.st_size);
t->items[7] = MP_OBJ_NEW_SMALL_INT(sb.st_atime);
t->items[8] = MP_OBJ_NEW_SMALL_INT(sb.st_mtime);
t->items[9] = MP_OBJ_NEW_SMALL_INT(sb.st_ctime);
diff --git a/unix/modsocket.c b/unix/modsocket.c
index c7be6461e8..c612f870d9 100644
--- a/unix/modsocket.c
+++ b/unix/modsocket.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@@ -391,7 +391,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_socket_htons_obj, mod_socket_htons);
STATIC mp_obj_t mod_socket_gethostbyname(mp_obj_t arg) {
- assert(MP_OBJ_IS_TYPE(arg, &mp_type_str));
const char *s = mp_obj_str_get_str(arg);
struct hostent *h = gethostbyname(s);
if (h == NULL) {
@@ -441,9 +440,7 @@ STATIC mp_obj_t mod_socket_inet_ntop(mp_obj_t family_in, mp_obj_t binaddr_in) {
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_socket_inet_ntop_obj, mod_socket_inet_ntop);
STATIC mp_obj_t mod_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) {
- // TODO: Implement all args
- assert(n_args >= 2 && n_args <= 4);
- assert(MP_OBJ_IS_STR(args[0]));
+ // TODO: Implement 5th and 6th args
const char *host = mp_obj_str_get_str(args[0]);
const char *serv = NULL;
@@ -510,7 +507,7 @@ STATIC mp_obj_t mod_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) {
freeaddrinfo(addr_list);
return list;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_socket_getaddrinfo_obj, 2, 6, mod_socket_getaddrinfo);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_socket_getaddrinfo_obj, 2, 4, mod_socket_getaddrinfo);
STATIC mp_obj_t mod_socket_sockaddr(mp_obj_t sockaddr_in) {
mp_buffer_info_t bufinfo;
diff --git a/unix/modtermios.c b/unix/modtermios.c
index 5e82e772ac..fe19aac83c 100644
--- a/unix/modtermios.c
+++ b/unix/modtermios.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
diff --git a/unix/modtime.c b/unix/modtime.c
index 080d321ee4..a74b81f374 100644
--- a/unix/modtime.c
+++ b/unix/modtime.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@@ -125,21 +125,40 @@ STATIC mp_obj_t mod_time_sleep(mp_obj_t arg) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_time_sleep_obj, mod_time_sleep);
-STATIC mp_obj_t mod_time_strftime(size_t n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mod_time_localtime(size_t n_args, const mp_obj_t *args) {
time_t t;
- if (n_args == 1) {
+ if (n_args == 0) {
t = time(NULL);
} else {
- // CPython requires passing struct tm, but we allow to pass time_t
- // (and don't support struct tm so far).
- t = mp_obj_get_int(args[1]);
+ #if MICROPY_PY_BUILTINS_FLOAT
+ mp_float_t val = mp_obj_get_float(args[0]);
+ t = (time_t)MICROPY_FLOAT_C_FUN(trunc)(val);
+ #else
+ t = mp_obj_get_int(args[0]);
+ #endif
}
struct tm *tm = localtime(&t);
- char buf[32];
- size_t sz = strftime(buf, sizeof(buf), mp_obj_str_get_str(args[0]), tm);
- return mp_obj_new_str(buf, sz, false);
+
+ mp_obj_t ret = mp_obj_new_tuple(9, NULL);
+
+ mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(ret);
+ tuple->items[0] = MP_OBJ_NEW_SMALL_INT(tm->tm_year + 1900);
+ tuple->items[1] = MP_OBJ_NEW_SMALL_INT(tm->tm_mon + 1);
+ tuple->items[2] = MP_OBJ_NEW_SMALL_INT(tm->tm_mday);
+ tuple->items[3] = MP_OBJ_NEW_SMALL_INT(tm->tm_hour);
+ tuple->items[4] = MP_OBJ_NEW_SMALL_INT(tm->tm_min);
+ tuple->items[5] = MP_OBJ_NEW_SMALL_INT(tm->tm_sec);
+ int wday = tm->tm_wday - 1;
+ if (wday < 0) {
+ wday = 6;
+ }
+ tuple->items[6] = MP_OBJ_NEW_SMALL_INT(wday);
+ tuple->items[7] = MP_OBJ_NEW_SMALL_INT(tm->tm_yday + 1);
+ tuple->items[8] = MP_OBJ_NEW_SMALL_INT(tm->tm_isdst);
+
+ return ret;
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_time_strftime_obj, 1, 2, mod_time_strftime);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_time_localtime_obj, 0, 1, mod_time_localtime);
STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_utime) },
@@ -153,7 +172,7 @@ STATIC const mp_rom_map_elem_t mp_module_time_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_ticks_cpu), MP_ROM_PTR(&mp_utime_ticks_cpu_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_add), MP_ROM_PTR(&mp_utime_ticks_add_obj) },
{ MP_ROM_QSTR(MP_QSTR_ticks_diff), MP_ROM_PTR(&mp_utime_ticks_diff_obj) },
- { MP_ROM_QSTR(MP_QSTR_strftime), MP_ROM_PTR(&mod_time_strftime_obj) },
+ { MP_ROM_QSTR(MP_QSTR_localtime), MP_ROM_PTR(&mod_time_localtime_obj) },
};
STATIC MP_DEFINE_CONST_DICT(mp_module_time_globals, mp_module_time_globals_table);
diff --git a/unix/moduselect.c b/unix/moduselect.c
index 37a3a33b28..ba1c195ef4 100644
--- a/unix/moduselect.c
+++ b/unix/moduselect.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
diff --git a/unix/mpconfigport.h b/unix/mpconfigport.h
index 047121fe66..b557f3d448 100644
--- a/unix/mpconfigport.h
+++ b/unix/mpconfigport.h
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@@ -24,7 +24,7 @@
* THE SOFTWARE.
*/
-// options to control how Micro Python is built
+// options to control how MicroPython is built
#define MICROPY_ALLOC_PATH_MAX (PATH_MAX)
#define MICROPY_PERSISTENT_CODE_LOAD (1)
diff --git a/unix/mpconfigport.mk b/unix/mpconfigport.mk
index 8819546bfe..f0aa955c0c 100644
--- a/unix/mpconfigport.mk
+++ b/unix/mpconfigport.mk
@@ -4,7 +4,7 @@
MICROPY_FORCE_32BIT = 0
# This variable can take the following values:
-# 0 - no readline, just simple input
+# 0 - no readline, just simple stdin input
# 1 - use MicroPython version of readline
MICROPY_USE_READLINE = 1
@@ -23,9 +23,15 @@ MICROPY_PY_SOCKET = 1
# ffi module requires libffi (libffi-dev Debian package)
MICROPY_PY_FFI = 1
-# ussl module requires axtls
+# ussl module requires one of the TLS libraries below
MICROPY_PY_USSL = 1
+# axTLS has minimal size and fully integrated with MicroPython, but
+# implements only a subset of modern TLS functionality, so may have
+# problems with some servers.
MICROPY_SSL_AXTLS = 1
+# mbedTLS is more up to date and complete implementation, but also
+# more bloated. Configuring and building of mbedTLS should be done
+# outside of MicroPython, it can just link with mbedTLS library.
MICROPY_SSL_MBEDTLS = 0
# jni module requires JVM/JNI
diff --git a/unix/mpconfigport_coverage.h b/unix/mpconfigport_coverage.h
index 5fc8d7107a..a9e0a38fa0 100644
--- a/unix/mpconfigport_coverage.h
+++ b/unix/mpconfigport_coverage.h
@@ -37,6 +37,7 @@
#define MICROPY_PY_DELATTR_SETATTR (1)
#define MICROPY_PY_BUILTINS_HELP (1)
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
+#define MICROPY_PY_SYS_GETSIZEOF (1)
#define MICROPY_PY_URANDOM_EXTRA_FUNCS (1)
#define MICROPY_PY_IO_BUFFEREDWRITER (1)
#undef MICROPY_VFS_FAT
diff --git a/unix/mpconfigport_fast.h b/unix/mpconfigport_fast.h
index b5be9f334f..442159eb4f 100644
--- a/unix/mpconfigport_fast.h
+++ b/unix/mpconfigport_fast.h
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
diff --git a/unix/mpconfigport_minimal.h b/unix/mpconfigport_minimal.h
index b4d9f81439..ef7a1a09a0 100644
--- a/unix/mpconfigport_minimal.h
+++ b/unix/mpconfigport_minimal.h
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
@@ -24,7 +24,7 @@
* THE SOFTWARE.
*/
-// options to control how Micro Python is built
+// options to control how MicroPython is built
#define MICROPY_ALLOC_QSTR_CHUNK_INIT (64)
#define MICROPY_ALLOC_PARSE_RULE_INIT (8)
@@ -97,7 +97,7 @@
extern const struct _mp_obj_module_t mp_module_os;
#define MICROPY_PORT_BUILTIN_MODULES \
- { MP_OBJ_NEW_QSTR(MP_QSTR_uos), (mp_obj_t)&mp_module_os }, \
+ { MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_os) }, \
#define MICROPY_PORT_ROOT_POINTERS \
diff --git a/unix/mphalport.h b/unix/mphalport.h
index cf227872f9..ff7a51567c 100644
--- a/unix/mphalport.h
+++ b/unix/mphalport.h
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
diff --git a/unix/mpthreadport.h b/unix/mpthreadport.h
index 51cf8d7860..b158ed5bcc 100644
--- a/unix/mpthreadport.h
+++ b/unix/mpthreadport.h
@@ -23,8 +23,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#ifndef __MICROPY_INCLUDED_UNIX_MPTHREADPORT_H__
-#define __MICROPY_INCLUDED_UNIX_MPTHREADPORT_H__
#include <pthread.h>
@@ -32,5 +30,3 @@ typedef pthread_mutex_t mp_thread_mutex_t;
void mp_thread_init(void);
void mp_thread_gc_others(void);
-
-#endif // __MICROPY_INCLUDED_UNIX_MPTHREADPORT_H__
diff --git a/unix/qstrdefsport.h b/unix/qstrdefsport.h
index 8ab2db58f5..ebfaa6ccab 100644
--- a/unix/qstrdefsport.h
+++ b/unix/qstrdefsport.h
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
diff --git a/unix/unix_mphal.c b/unix/unix_mphal.c
index 800484498e..02cdbea11f 100644
--- a/unix/unix_mphal.c
+++ b/unix/unix_mphal.c
@@ -1,5 +1,5 @@
/*
- * This file is part of the Micro Python project, http://micropython.org/
+ * This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*