Wykres commitów

7794 Commity (8109cd5f23c530ef568c617c85193cfa9b836dbc)

Autor SHA1 Wiadomość Data
Paul Sokolovsky 8109cd5f23 extmod/crypto-algorithms/sha256: Remove non-standard memory.h header. 2017-04-27 15:01:01 +03:00
Paul Sokolovsky 31bbcd448c zephyr/modusocket: Add dummy makefile() implementation. 2017-04-27 14:57:49 +03:00
Paul Sokolovsky 868453d3d8 zephyr/modusocket: sock_read: Check socket status only at the start of packet.
Otherwise, if we already have a packet in progress, finish it first, before
check "peer closed" status.
2017-04-26 09:14:41 +03:00
Paul Sokolovsky 1fe0f678f8 zephyr/modusocket: Add read/readline/readinto stream methods. 2017-04-26 08:43:07 +03:00
Paul Sokolovsky ef55be159c zephyr/modusocket: Refactor recv() into stream read() method. 2017-04-26 08:43:07 +03:00
Damien George 7743b1523e unix: Remove obsolete MICROPY_FATFS macro.
It doesn't do anything.  The VFS feature is controlled by MICROPY_VFS and
the FatFS driver, by MICROPY_VFS_FAT (which are set in mpconfigport.h).
2017-04-26 11:16:52 +10:00
Paul Sokolovsky 63068875c5 zephyr/modusocket: Enable stream write() method. 2017-04-26 01:06:42 +03:00
Paul Sokolovsky 0e177e0649 zephyr/modusocket: Refactor send() into stream write() method. 2017-04-26 01:05:54 +03:00
Kushal Das 083cd21a74 zephyr: Add 96b_carbon configuration.
As there's no networking support in mainline yet, networking is disabled,
because otherwise the board hangs on startup.
2017-04-26 00:22:48 +03:00
Damien George f85fd79c6c py/mpz: In mpn_sub, use existing function to remove trailing zeros. 2017-04-25 12:22:04 +10:00
Damien George 810133d97d tests/basics: Add tests for int.from_bytes when src has trailing zeros.
The trailing zeros should be truncated from the converted value.
2017-04-25 12:07:02 +10:00
Damien George c7aa86ce6f py/mpz: Strip trailing zeros from mpz value when set from bytes. 2017-04-25 12:06:10 +10:00
Paul Sokolovsky 5e66f2b751 zephyr/main: Configure IPv4 netmask and gateway to allow Internet access. 2017-04-22 19:29:47 +03:00
Damien George 30badd1ce1 tests: Add tests for calling super and loading a method directly. 2017-04-22 23:39:38 +10:00
Damien George dd11af209d py: Add LOAD_SUPER_METHOD bytecode to allow heap-free super meth calls.
This patch allows the following code to run without allocating on the heap:

    super().foo(...)

Before this patch such a call would allocate a super object on the heap and
then load the foo method and call it right away.  The super object is only
needed to perform the lookup of the method and not needed after that.  This
patch makes an optimisation to allocate the super object on the C stack and
discard it right after use.

Changes in code size due to this patch are:

   bare-arm: +128
    minimal: +232
   unix x64: +416
unix nanbox: +364
     stmhal: +184
    esp8266: +340
     cc3200: +128
2017-04-22 23:39:20 +10:00
Damien George 5335942b59 py/compile: Refactor handling of special super() call.
This patch refactors the handling of the special super() call within the
compiler.  It removes the need for a global (to the compiler) state variable
which keeps track of whether the subject of an expression is super.  The
handling of super() is now done entirely within one function, which makes
the compiler a bit cleaner and allows to easily add more optimisations to
super calls.

Changes to the code size are:

   bare-arm: +12
    minimal:  +0
   unix x64: +48
unix nanbox: -16
     stmhal:  +4
     cc3200:  +0
    esp8266: -56
2017-04-22 21:46:32 +10:00
Damien George 0dd6a59c89 py/compile: Don't do unnecessary check if iter parse node is a struct.
If we get to this point in the code then pn_iter is guaranteed to be a
struct.
2017-04-22 21:43:42 +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
Damien George ae54fbf166 py/compile: Add COMP_RETURN_IF_EXPR option to enable return-if-else opt.
With this optimisation enabled the compiler optimises the if-else
expression within a return statement.  The optimisation reduces bytecode
size by 2 bytes for each use of such a return-if-else statement.  Since
such a statement is not often used, and costs bytes for the code, the
feature is disabled by default.

For example the following code:

    def f(x):
        return 1 if x else 2

compiles to this bytecode with the optimisation disabled (left column is
bytecode offset in bytes):

    00 LOAD_FAST 0
    01 POP_JUMP_IF_FALSE 8
    04 LOAD_CONST_SMALL_INT 1
    05 JUMP 9
    08 LOAD_CONST_SMALL_INT 2
    09 RETURN_VALUE

and to this bytecode with the optimisation enabled:

    00 LOAD_FAST 0
    01 POP_JUMP_IF_FALSE 6
    04 LOAD_CONST_SMALL_INT 1
    05 RETURN_VALUE
    06 LOAD_CONST_SMALL_INT 2
    07 RETURN_VALUE

So the JUMP to RETURN_VALUE is optimised and replaced by RETURN_VALUE,
saving 2 bytes and making the code a bit faster.
2017-04-22 14:58:01 +10:00
Damien George 40b40ffc98 py/compile: Extract parse-node kind at start of func for efficiency.
Otherwise the type of parse-node and its kind has to be re-extracted
multiple times.  This optimisation reduces code size by a bit (16 bytes on
bare-arm).
2017-04-22 14:23:47 +10:00
Damien George fa03bbf0fd py/compile: Don't do unnecessary check if parse node is a struct.
PN_atom_expr_normal parse nodes always have structs for their second
sub-node, so simplify the check for the sub-node kind to save code size.
2017-04-22 14:13:37 +10:00
Damien George 4df013c8cc py/objtype: mp_obj_new_super doesn't need to be public, so inline it.
Saves code size (20 bytes on bare-arm) and makes it a tiny bit more
efficient.
2017-04-22 12:14:04 +10:00
Paul Sokolovsky 9e8f316392 extmod/moductypes: Fix bigint handling for 32-bit ports. 2017-04-21 16:43:21 +03: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 7a72c0db5a py: Reduce str/repr precision of float numbers when floats are 30-bit.
With 30-bit floats there aren't enough bits to faithfully print 7 decimal
digits, so reduce the precision to 6 digits.
2017-04-21 16:21:56 +10:00
Paul Sokolovsky 5846770997 zephyr/modmachine: Implement machine.reset(). 2017-04-19 13:28:36 +03:00
Henrik Sölver 1f3887dc28 stmhal/timer: Clear interrupt flag before setting callback.
Sometimes when setting a channel callback the callback fires immediately,
even if the compare register is set to a value far into the future. This
happens when the free running counter has previously been equal to what
happens to be in the compare register.

This patch make sure that there is no pending interrupt when setting a
callback.
2017-04-18 18:09:59 +10:00
Damien George c7c14f1634 tests/micropython: Add test for micropython.kbd_intr(). 2017-04-18 17:24:30 +10:00
Damien George bbb4b9822f py/modmicropython: Add micropython.kbd_intr() function.
It controls the character that's used to (asynchronously) raise a
KeyboardInterrupt exception.  Passing "-1" allows to disable the
interception of the interrupt character (as long as a port allows such a
behaviour).
2017-04-18 17:24:30 +10:00
Damien George 29b26f3922 docs/library/machine.SPI: Fix formatting of bullet list to stop warning. 2017-04-18 15:40:04 +10:00
Damien George 850f79e552 docs/library/machine.I2C: Remove WiPy-specific return values.
cc3200 has been updated to conform to the API and now returns None.
2017-04-18 15:39:27 +10:00
Damien George 9d7c53734c cc3200/mods/pybi2c: Make readfnom_mem_into/writeto_mem return None.
This aligns the I2C class to match the standard machine.I2C API.

Note that this is a (small) breaking change to the existing cc3200 API.
The original API just returned the size of the input buffer so there's no
information lost by this change.  To update scripts users should just use
the size of the buffer passed to these functions to get the number of bytes
that are read/written.
2017-04-18 15:31:08 +10:00
Damien George daa5ba5629 docs/esp8266/quickref: Add links from quickref page to machine classes. 2017-04-18 15:28:18 +10:00
Damien George d4675e7674 docs/library/machine.*: Add cross-reference label to individual classes. 2017-04-18 15:27:37 +10:00
Damien George 1f1a03d0c3 docs/library/machine.I2C: Deconditionalise all methods.
The cc3200 port is now similar enough to the standard machine.I2C API so
that all conditionals can be removed.
2017-04-18 15:04:51 +10:00
Damien George c49b265389 docs/wipy/general: Add section about specifics of I2C implementation. 2017-04-18 15:04:30 +10:00
Damien George 27f0862550 docs/wipy/quickref: Update reference for change to I2C API. 2017-04-18 13:20:07 +10:00
Damien George 8f205c2c9b cc3200/mods/pybi2c: Make machine.I2C constructor/init conform to HW API.
This is a user-facing change to the cc3200's API, to make it conform to the
new machine hardware API.  The changes are:

- change I2C constructor to: I2C(id=0, *, freq=100000, scl=None, sda=None)
- change I2C init to: init(*, freq, scl, sda)
- removal of machine.I2C.MASTER constant
- I2C str/repr no longer prints I2C.MASTER

To update existing code it should be enough to just remove the I2C.MASTER
constant from contructor/init for I2C.
2017-04-18 13:16:05 +10:00
Damien George fabaa61437 docs/library/machine.UART: Remove pyboard-specific section.
stmhal doesn't have a machine.UART class so this section is not needed.
2017-04-18 12:13:51 +10:00
Damien George e75fd3a8e9 minimal/main: Make Cortex-M vector table constant. 2017-04-18 10:17:24 +10:00
Paul Sokolovsky 57b5ee2fcf tests/run-tests: Don't post-process CRASH result in any way.
If we got a CRASH result, return early, similar to SKIP. This is important
because previous refactor changed branching logic a bit, so CRASH now gets
post-processed into CRASH\n, which broke remote hardware tests.
2017-04-16 17:59:11 +03:00
Paul Sokolovsky a78703f188 docs/library/machine: Typo fix in machine_callbacks section. 2017-04-16 10:14:05 +03:00
Paul Sokolovsky 9ef6bb5480 docs/machine: Move machine.main() misnomer to wipy's known issues. 2017-04-16 10:12:01 +03:00
Paul Sokolovsky a8ece0358f docs/machine.UART: Deconditionalize normal methods. 2017-04-16 09:54:55 +03:00
Paul Sokolovsky ac8843ceec docs/library/ussl: Deconditionalize, wipy notes moved to its documentation. 2017-04-16 09:41:32 +03:00
Paul Sokolovsky a0fb360f1b docs/library/uos: urandom: Generalize description.
Don't give a guarantee of HW RNG, only a possibility of its usage.
2017-04-16 09:22:47 +03:00
Paul Sokolovsky ae831ec0a8 docs/library/micropython: Deconditionalize. 2017-04-16 09:18:47 +03:00
Damien George 61616e84ce extmod/machine_signal: Rename "inverted" arg to "invert", it's shorter.
A shorter name takes less code size, less room in scripts and is faster to
type at the REPL.

Tests and HW-API examples are updated to reflect the change.
2017-04-15 21:01:47 +03:00
Paul Sokolovsky 209eaec599 socket_send: Don't send more than MTU allows.
As Zephyr currently doesn't handle MTU itself (ZEP-1998), limit amount
of data we send on our side.

Also, if we get unsuccessful result from net_nbuf_append(), calculate
how much data it has added still. This works around ZEP-1984.
2017-04-14 19:46:27 +03:00
Paul Sokolovsky 5b8122f2bb tests/run-tests: Search feature checks wrt to main script location.
If run-tests script is run from another dir, we still want to look up
feature checks in run-tests' dir.
2017-04-14 17:07:13 +03:00