Commit Graph

71 Commits

Author SHA1 Message Date
Damien George 00e4f05907 windows: Convert to use core-provided version of built-in import(). 2017-06-01 16:29:02 +10:00
Damien George 03053f82db mpy-cross, unix, windows, stmhal: Enable return-if-else optimisation.
Prior to making this a config option it was previously available on these
(and all other) ports, and it makes sense to keep it enabled for mpy-cross
as well as ports that have a decent amount of space for the code.
2017-04-22 15:12:48 +10:00
stijn 3e5cd35a9f windows: Bring mpconfigport.h up-to-date with unix port
Add definitions/source files for features which work on the windows
ports but weren't yet enabled.
UTIME related lines are moved a couple of lines up to make comparision
with unix/mpconfigport.h easier in the future.
2017-04-21 13:20:14 +02:00
Damien George 6c564aa408 unix, windows: Use core-provided KeyboardInterrupt exception object. 2017-04-11 13:31:49 +10:00
Damien George 4c307bfba1 all: Move BYTES_PER_WORD definition from ports to py/mpconfig.h
It can still be overwritten by a port in mpconfigport.h but for almost
all cases one can use the provided default.
2017-04-01 11:39:38 +11:00
Damien George 32e98257e2 windows: Enable READER_POSIX to get access to lexer_new_from_file. 2016-11-16 20:27:12 +11:00
Paul Sokolovsky 6a2c6098f4 windows: Enable utime_mphal following unix, define mp_hal_ticks_*.
mp_hal_ticks_ms, mp_hal_ticks_us taken from unix port, mp_hal_ticks_cpu
dummy.
2016-10-29 14:32:15 +03:00
stijn d14d4cdb8b windows: Enable MICROPY_PY_UERRNO
This also fixes the test failure for vfs_fat_ramdisk.py
2016-09-10 10:15:30 +10:00
Damien George 675d1c9c60 ports: Remove typedef of machine_ptr_t, it's no longer needed.
This type was used only for the typedef of mp_obj_t, which is now defined
by the object representation.  So we can now remove this unused typedef,
to simplify the mpconfigport.h file.
2016-08-15 11:02:59 +10:00
stijn 4b9046328d windows/msvc: Include machine_pinbase.c in build and enable umachine module
Fixes linker errors since [ad229477] and adds the umachine module so tests pass.
2016-06-25 21:49:45 +01:00
Paul Sokolovsky 10e5e10393 windows: Follow unix port changes regarding "utime" module. 2016-06-18 00:17:18 +03:00
Paul Sokolovsky 9b0714b24c py: Declare help, input, open builtins in core.
These are *defined* per-port, but why redeclare them again and again.
2016-04-15 00:07:56 +03:00
Damien George 0a2e9650f5 py: Add ability to have frozen persistent bytecode from .mpy files.
The config variable MICROPY_MODULE_FROZEN is now made of two separate
parts: MICROPY_MODULE_FROZEN_STR and MICROPY_MODULE_FROZEN_MPY.  This
allows to have none, either or both of frozen strings and frozen mpy
files (aka frozen bytecode).
2016-04-13 16:07:47 +01:00
Paul Sokolovsky d3b1f0b627 py/runtime: mp_stack_ctrl_init() should be called immediately on startup.
Calling it from mp_init() is too late for some ports (like Unix), and leads
to incomplete stack frame being captured, with following GC issues. So, now
each port should call mp_stack_ctrl_init() on its own, ASAP after startup,
and taking special precautions so it really was called before stack variables
get allocated (because if such variable with a pointer is missed, it may lead
to over-collecting (typical symptom is segfaulting)).
2016-01-29 02:13:42 +02:00
Damien George d22bdad6dd windows: Enable urandom module. 2016-01-26 15:27:00 +00:00
Paul Sokolovsky 1e06e81b3d windows: Propagate MICROPY_PY_OS_DUPTERM handling from unix port. 2015-12-28 01:30:58 +02:00
Paul Sokolovsky 5efd3f0dca windows: Make keyboard_interrupt_obj available, it's standard feature. 2015-12-18 01:07:27 +02:00
Paul Sokolovsky a6eff059b9 unix: Rename "_os" module to "uos" for consistency with baremetal ports. 2015-12-12 00:04:35 +02:00
stijn 3baf6b5319 windows/py: Support 64bit mingw-w64 builds
- add mp_int_t/mp_uint_t typedefs in mpconfigport.h
- fix integer suffixes/formatting in mpconfig.h and mpz.h
- use MICROPY_NLR_SETJMP=1 in Makefile since the current nlrx64.S
  implementation causes segfaults in gc_free()
- update README
2015-11-24 17:34:14 +02:00
stijn 5be60d6929 windows: Define ssize_t and use renamed mphal header
This fixes the build after changes in [66fd3e4] and [3a6b3d2]
2015-11-14 02:06:55 +02:00
Damien George 731f359292 all: Add py/mphal.h and use it in all ports.
py/mphal.h contains declarations for generic mp_hal_XXX functions, such
as stdio and delay/ticks, which ports should provide definitions for.  A
port will also provide mphalport.h with further HAL declarations.
2015-10-31 19:14:30 +03:00
stijn bd9f850e85 windows: Use write() instead of fwrite() to avoid out-of-order output.
This fixes the basics/exception_chain.py test, also see #1500 for more
info and [4300c7d] where the same change was done for the other ports.
2015-10-31 14:10:13 +03:00
stijn f3e46d0c52 windows: Rename "time" module to "utime" for consistency with others. 2015-10-26 11:42:10 +00:00
stijn ca9eb81d0b windows: Add usleep() implementation for msvc port
Also make sleep.c self-contained by moving initialization code,
instead of having part of the code in init.c, and add a header file
to accomodate this.
msec_sleep() now uses the usleep() implementation as well.
2015-10-25 15:42:19 +03:00
stijn 941040e9e8 windows: Make mpconfigport.h up-to-date with the unix port 2015-09-23 07:10:00 -07:00
stijn 3179d23cee windows: Make unistd.h more posix compatible
- add SEEK_XXX definitions, this fixes missing definition in py/stream.c
- move R_OK from realpath.c and add W_OK/F_OK defintions
- move STDXXX_FILENO definitions from mpconfigport for consistency
2015-08-14 12:04:23 +02:00
stijn 87ad80edf9 windows: Implement the mp_hal_xxx functions and enable mp-readline 2015-06-04 19:22:13 +03:00
stijn 861670ba2a py: Implement mp_format_float for doubles and use where appropriate
This allows using (almost) the same code for printing floats everywhere,
removes the dependency on sprintf and uses just snprintf and
applies an msvc-specific fix for snprintf in a single place so
nan/inf are now printed correctly.
2015-05-17 21:47:11 +01:00
stijn a09757f104 windows: Enable some recently added features in mpconfigport.h 2015-05-13 16:26:16 +01:00
Damien George 7f9d1d6ab9 py: Overhaul and simplify printf/pfenv mechanism.
Previous to this patch the printing mechanism was a bit of a tangled
mess.  This patch attempts to consolidate printing into one interface.

All (non-debug) printing now uses the mp_print* family of functions,
mainly mp_printf.  All these functions take an mp_print_t structure as
their first argument, and this structure defines the printing backend
through the "print_strn" function of said structure.

Printing from the uPy core can reach the platform-defined print code via
two paths: either through mp_sys_stdout_obj (defined pert port) in
conjunction with mp_stream_write; or through the mp_plat_print structure
which uses the MP_PLAT_PRINT_STRN macro to define how string are printed
on the platform.  The former is only used when MICROPY_PY_IO is defined.

With this new scheme printing is generally more efficient (less layers
to go through, less arguments to pass), and, given an mp_print_t*
structure, one can call mp_print_str for efficiency instead of
mp_printf("%s", ...).  Code size is also reduced by around 200 bytes on
Thumb2 archs.
2015-04-16 14:30:16 +00:00
stijn 28fa84b445 py: Add optional support for descriptors' __get__ and __set__ methods.
Disabled by default.  Enabled on unix and windows ports.
2015-03-26 23:55:14 +00:00
Damien George 42e0c59308 py: Add MICROPY_COMP_{DOUBLE,TRIPLE}_TUPLE_ASSIGN config options.
These allow to fine-tune the compiler to select whether it optimises
tuple assignments of the form a, b = c, d and a, b, c = d, e, f.
Sensible defaults are provided.
2015-03-14 13:11:35 +00:00
Damien George d891452a73 py: Add MICROPY_MALLOC_USES_ALLOCATED_SIZE to allow simpler malloc API. 2015-03-03 21:23:13 +00:00
Damien George 5b76e3b75e windows: Enable MICROPY_STACK_CHECK. 2015-01-12 15:34:53 +00:00
Damien George ddd1e18801 py: Add config option MICROPY_COMP_MODULE_CONST for module consts.
Compiler optimises lookup of module.CONST when enabled (an existing
feature).  Disabled by default; enabled for unix, windows, stmhal.
Costs about 100 bytes ROM on stmhal.
2015-01-10 14:07:24 +00:00
Damien George a9a0862078 windows: Enable MICROPY_PY_MICROPYTHON_MEM_INFO. 2015-01-09 20:30:26 +00:00
stijn afd6c8e1d2 Remove obsolete bss-related code/build features
GC for unix/windows builds doesn't make use of the bss section anymore,
so we do not need the (sometimes complicated) build features and code related to it
2015-01-08 15:29:44 +01:00
stijn 51af362e31 msvc: Define no-op MP_LIKELY/UNLIKELY since there's no __builtin_expect 2015-01-04 13:29:02 +02:00
stijn f5efefd5a0 windows: Correctly interpret skipped tests, enable uhashlib and ubinascii 2014-12-20 16:52:22 +02:00
Damien George 78d702c300 py: Allow builtins to be overridden.
This patch adds a configuration option (MICROPY_CAN_OVERRIDE_BUILTINS)
which, when enabled, allows to override all names within the builtins
module.  A builtins override dict is created the first time the user
assigns to a name in the builtins model, and then that dict is searched
first on subsequent lookups.  Note that this implementation doesn't
allow deleting of names.

This patch also does some refactoring of builtins code, creating the
modbuiltins.c file.

Addresses issue #959.
2014-12-09 16:19:48 +00:00
stijn b89eaaa2e2 windows: Update config with latest features
- update mpconfigport.h to reflect latest unix version
- fix compilation error in modure due to msvc not allowing dynamic arrays
2014-11-21 19:38:33 +00:00
Paul Sokolovsky 91386eee26 ports: Define mp_off_t. 2014-11-17 00:16:14 +02:00
Paul Sokolovsky e6c5a63fab windows: Enable moduzlib instead of modzlibd. 2014-10-13 14:12:32 +03:00
Paul Sokolovsky 5d328cbeb9 windows: mingw32 gcc doesn't define endianness macros, so just assume little.
Specifically, at least Ubuntu's i586-mingw32msvc-gcc doesn't supply
__LITTLE_ENDIAN__ and friends. And as it's safe enough to assume that
Windows is only little-endian, then it's defined unconditionally,
instead of duplicating detection logic in py/mpconfig.h (or adding
windows-specific defines to it).
2014-10-06 23:18:59 +03:00
stijn a2f9c9445a Enable unicode for Windows port so unicode tests give correct uPy output 2014-10-04 09:16:20 +02:00
stijn 8c41920a90 windows: Enable input(), sys.maxsize(), ujson module, emergency exception buf, os module 2014-09-22 11:10:27 +02:00
stijn 759138caee msvc: Exclude modtermios, include extmod and fix compilation error 2014-09-02 09:00:20 +02:00
Damien George 3c658a4e75 py: Fix bug where GC collected native/viper/asm function data.
Because (for Thumb) a function pointer has the LSB set, pointers to
dynamic functions in RAM (eg native, viper or asm functions) were not
being traced by the GC.  This patch is a comprehensive fix for this.

Addresses issue #820.
2014-08-24 16:28:17 +01:00
stijn 8cce8b7c4c msvc: Use built-in alignof
This also fixes a 'unnamed type definition in parentheses' warning on the
alignof implementation define in binary.c
2014-08-13 10:19:56 +02:00
Damien George 40f3c02682 Rename machine_(u)int_t to mp_(u)int_t.
See discussion in issue #50.
2014-07-03 13:25:24 +01:00