Commit Graph

6423 Commits

Author SHA1 Message Date
Damien George c93d9caa8b py/gc: Make memory manager and garbage collector thread safe.
By using a single, global mutex, all memory-related functions (alloc,
free, realloc, collect, etc) are made thread safe.  This means that only
one thread can be in such a function at any one time.
2016-06-28 11:28:49 +01:00
Damien George 34fc006f5e py/modthread: Add with-context capabilities to lock object. 2016-06-28 11:28:49 +01:00
Damien George 801d1b3803 py/modthread: Implement lock object, for creating a mutex. 2016-06-28 11:28:49 +01:00
Damien George 2dacd604c5 py/modthread: Add exit() function.
Simply raises the SystemExit exception.
2016-06-28 11:28:48 +01:00
Damien George 707f98f207 py/modthread: Add stack_size() function. 2016-06-28 11:28:48 +01:00
Damien George 3eb7a26809 py/modthread: Properly cast concrete exception pointer to an object. 2016-06-28 11:28:48 +01:00
Damien George a791be936a unix: Add basic thread support using pthreads.
Has the ability to create new threads.
2016-06-28 11:28:48 +01:00
Damien George 27cc07721b py: Add basic _thread module, with ability to start a new thread. 2016-06-28 11:28:48 +01:00
Damien George 330165a2cc py: Add MP_STATE_THREAD to hold state specific to a given thread. 2016-06-28 11:09:31 +01:00
Damien George 3545ef8bb4 tests/thread: Remove need to sleep to wait for completion in some tests.
Use a lock and a counter instead, and busy wait for all threads to
complete.  This makes test run faster and they no longer rely on the time
module.
2016-06-28 11:09:31 +01:00
Damien George 2d5ea38b49 tests: Add 3 more tests for _thread module. 2016-06-28 11:09:31 +01:00
Damien George ed36632c6c tests: Add tests for _thread module.
Includes functionality and stress tests.
2016-06-28 11:09:31 +01:00
Martin Müller f2892bd77d unix: Fix Makefile to handle gc-sections linker flags on Mac OS.
The linker flag --gc-sections is not available on the linker used on
Mac OS X which results in an error when linking micropython on Mac OS X.
Therefore move this option to the LDFLAGS_ARCH variable on non Darwin
systems. According to http://stackoverflow.com/a/17710056 the equivalent
to --gc-sections is -dead_strip thus this option is used for the
LDFLAGS_ARCH on Darwin systems.
2016-06-27 22:31:55 +01:00
Radomir Dopieralski ab8a5d5199 drivers/display/ssd1306: Add width arg and support 64px wide displays.
In particular, the WeMOS D1 Mini board comes with a shield that has a
64x48 OLED display. This patch makes it display properly, with the upper
left pixel being at (0, 0) and not (32, 0).

I tried to do this with the configuration commands, but there doesn't
seem to be a command that would set the column offset (there is one for
the line offset, though).
2016-06-26 13:09:31 +01:00
Robert HH eb7637ba2e esp8266/main.c: Clear the command line history when (re)booting.
Not clearing the command line history sometimes results in strange output
when going back after a reset.
2016-06-26 12:48:19 +01:00
Martin Müller 047ac2044d docs/library: Fix typo in docs for usocket.listen(). 2016-06-26 12:38:20 +01:00
Damien George 7ddd85f933 lib/libm: Remove unused definition of "one". 2016-06-25 22:30:40 +01:00
Damien George 873853f1a8 lib/libm: Format code to pass gcc v6.1.1 warning.
gcc 6.1.1 warns when indentation is misleading, and in this case the
formatting of the code really is misleading.  So adjust the formatting
to be clear of the meaning of the code.
2016-06-25 22:28:43 +01: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 0fb7a7a7ce tests/btree1: Add testcase for iterating btree object directly. 2016-06-24 23:43:20 +03:00
Paul Sokolovsky 2f7ebf16de extmod/modbtree: Cleverly implement "for key in btree:" syntax.
I.e. make it work like btree.keys(), while still not using a separate
iterator type.
2016-06-23 20:08:37 +03:00
Paul Sokolovsky d5835261af tests/extmod: Add "btree" module test. 2016-06-21 10:00:02 +03:00
Paul Sokolovsky 6b088a671a extmod/modbtree: Implement keys(), values(), items() iterators.
Each takes optional args of starting key, ending key, and flags (ending
key inclusive, reverse order).
2016-06-20 15:50:31 +03:00
Paul Sokolovsky 119b3dabf7 tests: Add a testcase for machine.PinBase class. 2016-06-19 19:45:29 +03:00
Paul Sokolovsky b2641b53e0 docs/conf.py: Exclude cmath from modindex for wipy. 2016-06-19 19:17:42 +03:00
Paul Sokolovsky 5071ceea07 extmod/modlwip: Store a chain of incoming pbufs, instead of only one.
Storing a chain of pbuf was an original design of @pfalcon's lwIP socket
module. The problem with storing just one, like modlwip does is that
"peer closed connection" notification is completely asynchronous and out of
band. So, there may be following sequence of actions:

1. pbuf #1 arrives, and stored in a socket.
2. pbuf #2 arrives, and rejected, which causes lwIP to put it into a
queue to re-deliver later.
3. "Peer closed connection" is signaled, and socket is set at such status.
4. pbuf #1 is processed.
5. There's no stored pbufs in teh socket, and socket status is "peer closed
connection", so EOF is returned to a client.
6. pbuf #2 gets redelivered.

Apparently, there's no easy workaround for this, except to queue all
incoming pbufs in a socket. This may lead to increased memory pressure,
as number of pending packets would be regulated only by TCP/IP flow
control, whereas with previous setup lwIP had a global overlook of number
packets waiting for redelivery and could regulate them centrally.
2016-06-19 19:15:20 +03:00
Paul Sokolovsky c7fba524cb py/objtype: Inherit protocol vtable from base class only if it exists. 2016-06-19 00:56:06 +03:00
Paul Sokolovsky efee577318 extmod/machine_pinbase: Fix nanbox build.
MP_ROM_PTR() is only for data structures initialization, code should use
MP_OBJ_FROM_PTR().
2016-06-19 00:26:57 +03:00
Paul Sokolovsky e68811dbbf unix/modmachine: Enable time_pulse_us() function. 2016-06-19 00:21:17 +03:00
Paul Sokolovsky 41167554e4 py/mphal.h: If virtpin API is used, automagically include its header. 2016-06-19 00:12:37 +03:00
Paul Sokolovsky 413c3e10b4 py/objtype: instance: Inherit protocol vtable from a base class.
This allows to define an  abstract base class which would translate
C-level protocol to Python method calls, and any subclass inheriting
from it will support this feature. This in particular actually enables
recently introduced machine.PinBase class.
2016-06-19 00:01:59 +03:00
Paul Sokolovsky ad229477c6 unix/modmachine: Include PinBase class. 2016-06-18 23:40:28 +03:00
Paul Sokolovsky 3fecbb2462 extmod/machine_pinbase: Implementation of PinBase class.
Allows to translate C-level pin API to Python-level pin API. In other
words, allows to implement a pin class and Python which will be usable
for efficient C-coded algorithms, like bitbanging SPI/I2C, time_pulse,
etc.
2016-06-18 23:40:28 +03:00
Paul Sokolovsky 2b6dcdd3e4 docs/sys: print_exception: Fixes/clarifications. 2016-06-18 19:06:53 +03:00
Paul Sokolovsky 617e033e2f docs/select: Add an article. 2016-06-18 19:06:42 +03:00
Paul Sokolovsky 07209f8592 all: Rename mp_obj_type_t::stream_p to protocol.
It's now used for more than just stream protocol (e.g. pin protocol), so
don't use false names.
2016-06-18 18:44:57 +03:00
Paul Sokolovsky 080137961d extmod/modbtree: open(): Support "in-memory" database with filename=None.
It's not really in-memory though, just uses anonymous temporary file on
disk.
2016-06-18 01:31:57 +03:00
Paul Sokolovsky e9739e3315 extmod/modbtree: __getitem__() should raise KeyError for non-existing key. 2016-06-18 01:30:49 +03:00
Paul Sokolovsky cbffd0aadd unix: Disable FatFs VFS for normal build, keep enabled for coverage.
It's enabled mostly for unit testing, and we do that in full with coverage
build.
2016-06-18 00:58:57 +03:00
Paul Sokolovsky e6e7e0e9c5 extmod/modbtree: items(): Implement DESC flag. 2016-06-18 00:47:26 +03:00
Paul Sokolovsky 7c8d76fad3 unix/alloc: Make coverage build and its overzealous warnings happy. 2016-06-18 00:36:13 +03:00
Paul Sokolovsky c9598604c6 unix/alloc: Add option to use uPy's alloc-exec implementation even for libffi.
When built for Linux, libffi includes very bloated and workaround exec-alloc
implementation required to work around SELinux and other "sekuritee" features
which real people don't use. MicroPython has own alloc-exec implementation,
used to alloc memory for @micropython.native code. With this option enabled,
uPy's implementation will override libffi's. This saves 11K on x86_64 (and
that accounts for more than half of the libffi code size).

TODO: Possibly, we want to refactor this option to allow either use uPy's
implementation even for libffi, or allow to use libffi's implementation even
for uPy.
2016-06-18 00:18:01 +03:00
Paul Sokolovsky 9b43a7d1be unix/Makefile: libffi: Build with -Os.
Also try to use -fno-exceptions. Other options taken from libffi's configure
defaults.
2016-06-18 00:17:47 +03:00
Paul Sokolovsky 10e5e10393 windows: Follow unix port changes regarding "utime" module. 2016-06-18 00:17:18 +03:00
Paul Sokolovsky 6f8880d0ab unix: Move "utime" module config to C level instead of make level. 2016-06-17 23:35:00 +03:00
Paul Sokolovsky 70536212d5 examples/unix/ffi_example.py: Remove TODO, make output more clear. 2016-06-17 19:24:58 +03:00
Paul Sokolovsky ecfd8e102d examples/unix/ffi_example.py: Update for current "ffi" module API. 2016-06-17 19:21:37 +03:00
Paul Sokolovsky df453f0652 unix: Time to build with --gc-sections.
This actually saves "only" 6K for x86_64 build, as we're still more or less
careful to #ifdef unneeded code. But relying on --gc-sections in a "lazy"
manner would allow to make #ifdef'ing less pervasive (not suggested right
away, but an option for the future).
2016-06-17 02:38:20 +03:00
Paul Sokolovsky 332545baa3 extmod/modbtree: items(): Implement "end key inclusive" flag. 2016-06-17 00:08:55 +03:00
Robert HH 23067a1422 esp8266: Use RTC to set date & time stamps for files.
The time stamp is taken from the RTC for all newly generated
or changed files. RTC must be maintained separately.
The dummy time stamp of Jan 1, 2000 is set in vfs.stat() for the
root directory, avoiding invalid time values.
2016-06-16 19:31:58 +03:00