Wykres commitów

421 Commity (73533247cb2602c968229d2c102e925c5b702677)

Autor SHA1 Wiadomość Data
Damien George c76af32575 unix/windows: Disable sigaction on windows port. 2014-10-26 00:42:41 +01:00
Damien George 124df6f8d0 py: Add mp_pending_exception global variable, for VM soft interrupt.
This allows to implement KeyboardInterrupt on unix, and a much safer
ctrl-C in stmhal port.  First ctrl-C is a soft one, with hope that VM
will notice it; second ctrl-C is a hard one that kills anything (for
both unix and stmhal).

One needs to check for a pending exception in the VM only for jump
opcodes.  Others can't produce an infinite loop (infinite recursion is
caught by stack check).
2014-10-25 23:37:57 +01:00
Damien George c9fc620723 py: Implement compile builtin, enabled only on unix port.
This should be pretty compliant with CPython, except perhaps for some
corner cases to do with globals/locals context.

Addresses issue #879.
2014-10-25 22:07:25 +01:00
Paul Sokolovsky fcff4663dd unix: Allow -X heapsize= option take numbers with K & M suffixes.
For kilobytes and megabytes respectively.
2014-10-25 17:00:55 +01:00
Damien George 0b13f3e026 py: Improve memory usage debugging; better GC AT dumping.
In unix port, mem_info(1) now prints pretty GC alloc table.
2014-10-24 23:12:25 +01:00
Damien George dd4f4530ab py: Add builtin memoryview object (mostly using array code). 2014-10-23 13:34:35 +01:00
Damien George f5d69794a8 extmod: Add uheapq module. 2014-10-22 23:20:15 +01:00
stijn 2fe4cf7761 Implement kwargs for builtin open() and _io.FileIO
This makes open() and _io.FileIO() more CPython compliant.
The mode kwarg is fully iplemented.
The encoding kwarg is allowed but not implemented; mainly to allow
the tests to specify encoding for CPython, see #874
2014-10-21 22:10:01 +03:00
Paul Sokolovsky 1a55b6a787 unix, stmhal: Implement file.readinto() method.
Also, usocket.readinto(). Known issue is that .readinto() should be available
only for binary files, but micropython uses single method table for both
binary and text files.
2014-10-18 22:44:07 +03:00
Damien George c92672d7f8 unix: Make -c option parse input script as a file, as per CPython.
Addresses issue #915.
2014-10-17 23:51:39 +01:00
Paul Sokolovsky 34162872b1 moduzlib: Integrate into the system. 2014-10-13 00:07:44 +03:00
Damien George 26fa3e30ec Merge branch 'modure' of https://github.com/pfalcon/micropython into pfalcon-modure 2014-10-11 18:49:02 +01:00
Paul Sokolovsky c36c75c4dc unix: Update comment MICROPY_GCREGS_SETJMP (untested -> undertested). 2014-10-11 20:33:44 +03:00
Paul Sokolovsky 6c2ab5c315 unix: Add comment about needed dependencies for MICROPY_FORCE_32BIT. 2014-10-11 20:33:37 +03:00
Paul Sokolovsky c71e045165 modure: Initial module, using re1.5 (which is based on re1 codebase).
https://github.com/pfalcon/re1.5
2014-10-11 14:36:32 +03:00
Paul Sokolovsky 23b3b04072 unix: Rename "microsocket" module to "usocket".
Per new conventions, we'd like to consistently use "u*" naming conventions
for modules which don't offer complete CPython compatibility, while offer
subset or similar API.
2014-10-09 20:43:10 +03:00
Dave Hylands 3556e45711 Allow real memory errors (from locked gc) to be reported with traceback. 2014-10-07 08:07:49 -07:00
Damien George 854c8c0153 unix: Detect and print compile error. 2014-10-05 22:25:36 +01:00
Damien George 39dc145478 py: Change [u]int to mp_[u]int_t in qstr.[ch], and some other places.
This should pretty much resolve issue #50.
2014-10-03 19:52:22 +01:00
Damien George 762d57519d unix: Do a proper clean-up on sys.exit/SystemExit.
Addresses issue #859.
2014-10-01 23:18:39 +01:00
Damien George 860805aae7 unix: Remove unnecessary #defines from config. 2014-09-29 19:41:49 +01:00
Damien George b0261341d3 py: For malloc and vstr functions, use size_t exclusively for int type.
It seems most sensible to use size_t for measuring "number of bytes" in
malloc and vstr functions (since that's what size_t is for).  We don't
use mp_uint_t because malloc and vstr are not Micro Python specific.
2014-09-25 15:49:26 +01:00
blmorris fa6567a39f Clean up logical flow for setting LDFLAGS to build for Linux and OSX
Add more specific comments describing what is going on.
2014-09-23 09:42:18 -04:00
blmorris 8afb9b3863 Incorporate change in assignment logic suggested by dhylands 2014-09-22 23:00:42 -04:00
blmorris 1fae787493 Fix unix/Makefile to build on OSX
Force OSX to compile with clang even if gcc is available
Change LDFLAGS syntax to be compatible with clang
Fix questionable syntax on line 90
Remove extraneous tab character
2014-09-22 15:16:14 -04:00
Damien George 612045f53f py: Add native json printing using existing print framework.
Also add start of ujson module with dumps implemented.  Enabled in unix
and stmhal ports.  Test passes on both.
2014-09-17 22:56:34 +01:00
Damien George b92cbe6129 py: Move definition of mp_sys_exit to core.
sys.exit always raises SystemExit so doesn't need a special
implementation for each port.  If C exit() is really needed, use the
standard os._exit function.

Also initialise mp_sys_path and mp_sys_argv in teensy port.
2014-09-15 15:53:09 +01:00
Damien George 91fe0d4880 unix: Fix modffi to be able to return double on x86 machines. 2014-09-06 23:04:42 +00:00
Damien George c90f59ec3a py: Add support for emitting native x86 machine code. 2014-09-06 23:06:36 +01:00
Damien George 17598d49e1 unix: Don't use -Wno-error=cpp or #warning; fix strict alias warning.
For the sake of older versions of gcc (and other compilers), don't use
the #warning CPP directive, nor the -Wno-error=cpp option.

Also, fix a strict alias warning in modffi.c for older compilers, and
add a test for ffi module.

Addresses issue #847.
2014-09-06 17:46:52 +01:00
Damien George dda46460ff Code style/whitespace cleanup; remove obsolete headers.
And move the MAP_ANON redefinition from py/asmx64.c to unix/alloc.c.
2014-09-03 22:47:23 +01:00
Damien George a669cbc690 unix: Auto-detect MICROPY_EMIT_X64 and MICROPY_GCREGS_SETJMP.
If not set, MICROPY_EMIT_X64 is set only if on x86-64 machine.

If not set, MICROPY_GCREGS_SETJMP is set when on MIPS.
2014-09-03 22:40:15 +01:00
Fabian Vogt b7235b8412 Add cache flush in py/asmarm.c and add new MP_PLAT_ALLOC_EXEC and MP_PLAT_FREE_EXEC macros
Fixes issue #840
2014-09-03 23:07:42 +02:00
Damien George 4abff7500f py: Change uint to mp_uint_t in runtime.h, stackctrl.h, binary.h.
Part of code cleanup, working towards resolving issue #50.
2014-08-30 14:59:21 +01:00
Damien George d182b98a37 py: Change all uint to mp_uint_t in obj.h.
Part of code cleanup, working towards resolving issue #50.
2014-08-30 14:19:41 +01:00
Damien George 9c4cbe2ac0 py: Make tuple and list use mp_int_t/mp_uint_t.
Part of code cleanup, to resolve issue #50.
2014-08-30 14:04:14 +01:00
Damien George ecc88e949c Change some parts of the core API to use mp_uint_t instead of uint/int.
Addressing issue #50, still some way to go yet.
2014-08-30 00:35:11 +01:00
Damien George db63660c19 Add pip-micropython to unix make install.
Also add -t/--target option to pip-micropython to allowing installing to
the pyboard.

Thanks to turbinenreiter/Sebastian Plamauer for the patch.
2014-08-26 16:03:57 +01: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
Damien George 25fc41dd31 unix, modtermios: Make it properly configurable; fix spelling mistake. 2014-08-24 13:19:22 +01:00
Paul Sokolovsky 4f9ebade60 modtermios: Add "termios" unix module, subset of CPython's.
Also provides setraw() function from "tty" module (which in CPython is
implemented in Python). The idea here is that 95% of "termios" module usage
is to set raw mode to allow access to normal serial devices. Then, instead
of exporting gazillion termios symbols, it's better to implement it in C,
and export minimal number of symbols (mostly baud rates and drain values).
2014-08-23 06:09:46 +03:00
Paul Sokolovsky 13ec400f28 Merge pull request #796 from turbinenreiter/makeinstall
unix: Added install/uninstall
2014-08-18 22:29:37 +03:00
Damien George 8f81b5cb4b py: Put SystemExit in builtin namespace.
Also fix unix port so that SystemExit with no arg exits with value 0.
2014-08-16 14:32:06 +01:00
Paul Sokolovsky 510296f25a modzlibd: Decompress part of "zlib" module, based on miniz tinfl.c . 2014-08-13 00:26:19 +03:00
Sebastian Plamauer 2eeeafcba5 added install/uninstall 2014-08-11 19:47:00 +02:00
Paul Sokolovsky 2831a8f800 modsocket: .recv() returns bytes object. 2014-08-10 21:24:47 +03:00
Damien George 8dbbbbc793 Put call to qstr_init and mp_init_emergency_exc_buf in mp_init.
qstr_init is always called exactly before mp_init, so makes sense to
just have mp_init call it.  Similarly with
mp_init_emergency_exception_buf.  Doing this makes the ports simpler and
less error prone (ie they can no longer forget to call these).
2014-08-04 10:05:16 +01:00
Damien George bb4c6f35c6 py: Make MP_OBJ_NEW_SMALL_INT cast arg to mp_int_t itself.
Addresses issue #724.
2014-07-31 10:49:14 +01:00
Damien George 07133415d2 Merge pull request #738 from dhylands/except-args
Add support for storing args during an exception raised by an irq.
2014-07-29 23:15:35 +01:00
Paul Sokolovsky d0f5e61ab5 py: Implement __file__ attribute for modules. 2014-07-28 21:21:59 +03:00
Damien George adf0f2ae1a py: Change stream protocol API: fns return uint; is_text for text. 2014-07-27 22:38:58 +01:00
Dave Hylands 5b7fd20fea Add support for storing args during an exception raised by an irq.
The user code should call micropython.alloc_emergency_exception_buf(size)
where size is the size of the buffer used to print the argument
passed to the exception.

With the test code from #732, and a call to
micropython.alloc_emergenncy_exception_buf(100) the following error is
now printed:
```python
>>> import heartbeat_irq
Uncaught exception in Timer(4) interrupt handler
Traceback (most recent call last):
  File "0://heartbeat_irq.py", line 14, in heartbeat_cb
NameError: name 'led' is not defined
```
2014-07-25 14:00:06 -07:00
Damien George 04c9fec7d1 Merge pull request #757 from stinos/windows-fsync
Add fsync for windows, i.e. _commit. See dce8876
2014-07-19 18:40:49 +01:00
Damien George 1694bc733d py: Add stream reading of n unicode chars; unicode support by default.
With unicode enabled, this patch allows reading a fixed number of
characters from text-mode streams; eg file.read(5) will read 5 unicode
chars, which can made of more than 5 bytes.

For an ASCII stream (ie no chars > 127) it only needs to do 1 read.  If
there are lots of non-ASCII chars in a stream, then it needs multiple
reads of the underlying object.

Adds a new test for this case.  Enables unicode support by default on
unix and stmhal ports.
2014-07-19 18:34:04 +01:00
stijn 73ab8cc21d Add fsync for windows, i.e. _commit. See dce8876 2014-07-16 09:37:09 +02:00
Paul Sokolovsky dce8876dbe unix: file: No fsync() on Windows. 2014-07-13 23:34:35 +03:00
Paul Sokolovsky 122c9db3db unix: file: Implement .flush() method.
This method apparently should be part of stream interface.
2014-07-13 23:14:24 +03:00
Paul Sokolovsky b82f34edde unix: Allow to disable MICROPY_EMIT_X64 from commandline.
emitnative in particular requires nlr_* to be real functions, so doesn't
compile with MICROPY_NLR_SETJMP=1.
2014-07-13 13:49:51 +03:00
Paul Sokolovsky 8215847b4d moductypes: Foreign data interface module, roughly based on ctype ideas.
But much smaller and memory-efficient. Uses Python builtin data structures
(dict, tuple, int) to describe structure layout.
2014-07-09 19:28:24 +03:00
Paul Sokolovsky 4e0eeebdc2 py: Implement sys.maxsize, standard way to check platform "bitness".
Implementing it as a static constant is a bit peculiar and require cooperation
from long int implementation.
2014-07-03 18:09:36 +03: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
Paul Sokolovsky caa7334141 stackctrl: Add "mp_" prefix. 2014-07-01 02:14:08 +03:00
Paul Sokolovsky e95b6b5e07 modffi: Add special 'C' code for passing a callback function pointer. 2014-07-01 02:05:34 +03:00
Paul Sokolovsky bb35f425f9 Merge pull request #730 from stinos/windows-mpconfig
windows: Sync mpconfigport.h with the unix' version
2014-06-29 20:50:16 +03:00
Paul Sokolovsky a23475979b modffi: Support short types. 2014-06-29 15:48:21 +03:00
stijn ec6fa8732b windows: Sync mpconfigport.h with the unix' version
- rearrange/add definitions that were not there so it's easier to compare both
- use MICROPY_PY_SYS_PLATFORM in main.c since it's available anyway
- define EWOULDBLOCK, it is missing from ingw32
2014-06-29 09:40:20 +02:00
stijn 5478ed18ea unix: Fix mpconfig.h not being included before misc.h
This fixes count_lead_ones in misc.h not compiling due to unknown types
2014-06-28 20:49:39 +02:00
Damien George 635b60e299 unix, stmhal: Add option for STR_UNICODE to mpconfigport.h.
Unicode is disabled by default for now, since FileIO.read(n) is
currently not implemented for text-mode files, and this is an
often function.
2014-06-28 10:29:52 +01:00
Paul Sokolovsky 8a96ebea75 py: Move stack_ctrl_init() to mp_init().
As stack checking is enabled by default, ports which don't call
stack_ctrl_init() are broken now (report RuntimeError on startup). Save
them trouble and just init stack control framework in interpreter init.
2014-06-27 21:02:04 +03:00
Paul Sokolovsky 3c8ce38d20 Merge pull request #717 from stinos/dead-code
unix: Remove unused CTRL-D definition
2014-06-27 01:23:18 +03:00
Paul Sokolovsky 23668698cb py: Add portable framework to query/check C stack usage.
Such mechanism is important to get stable Python functioning, because Python
function calling is handled with C stack. The idea is to sprinkle
STACK_CHECK() calls in places where there can be C recursion.

TODO: Add more STACK_CHECK()'s.
2014-06-27 00:03:55 +03:00
stijn 39b6e27944 unix: Remove unused CTRL-D definition 2014-06-25 13:33:10 +02:00
Paul Sokolovsky 939c2e7f44 Merge pull request #690 from stinos/msvc-gc
msvc: Enable GC
2014-06-24 21:34:51 +03:00
Paul Sokolovsky 3c9b24bebe modsocket: Fix uClibc detection. 2014-06-24 21:20:38 +03:00
Paul Sokolovsky 141df2d350 unix: Dump default heap size in usage message. 2014-06-24 16:58:00 +03:00
Paul Sokolovsky cd590cbfaa unix: Don't error out on #warning directive. 2014-06-22 19:20:55 +03:00
Paul Sokolovsky ff5932a8d8 modsocket: Workaround uClibc issue with numeric port for getaddrinfo().
It sucks to workaround this on uPy side, but upgrading not upgradable
embedded systems sucks even more.
2014-06-22 19:20:55 +03:00
Paul Sokolovsky 949a49c9da modsocket: Add call to freeaddrinfo(). 2014-06-22 19:11:34 +03:00
Paul Sokolovsky 69d0a1c540 unix: uClibc doesn't like NULL as a buffer arg to realpath().
So, allocate one explicitly.
2014-06-22 19:08:32 +03:00
stijn de5ce6d461 gc: Use simple cast instead of union to silence compiler 2014-06-22 11:32:32 +02:00
stijn 8abcf666cb windows: Enable GC and implement bss start and end symbols
The pointers to the bss section are acquired in init.c()
by inspecting the PE header. Works for msvc and mingw.
2014-06-22 11:31:16 +02:00
Paul Sokolovsky a96cc824bd py: Support arm and thumb ARM ISAs, in addition to thumb2.
These changes were tested with QEMU, and by few people of real hardware.
2014-06-22 01:40:45 +03:00
Paul Sokolovsky 17a49431d4 unix: Allow to override MICROPY_GCREGS_SETJMP from cmdline. 2014-06-20 20:22:31 +03:00
Paul Sokolovsky 7cd46a12ae unix: Add CFLAGS_EXTRA & LDFLAGS_EXTRA for command line usage.
The idea is that it should be possible to pass any additional params for
experimentation without need to patch sources (and without need to deviate
from or repeat baseline options).
2014-06-20 20:21:21 +03:00
Paul Sokolovsky 7e56e55252 unix: Refactor order file munging fo MacOSX. 2014-06-20 20:21:11 +03:00
Paul Sokolovsky eecf3e90c6 unix: Group CFLAGS related stuff together. 2014-06-20 20:21:11 +03:00
Paul Sokolovsky 2099b6897f unix: Allow to override compiler warning options without touching the rest.
Some people want to enable even more warnings. Let them do it without putting
burden on everyone. Some people vice versa think that current settings should
be relaxed. In this regard, -Werror is the most problematic, it disallows to
use #warning directive, and disallows to pass configuration settings on make
command lines. Again, until decided how to deal with these globally, allow to
work around these problems locally.
2014-06-20 20:18:08 +03:00
Emmanuel Blot f6932d6506 Prefix ARRAY_SIZE with micropython prefix MP_ 2014-06-19 18:54:34 +02:00
Damien George 4480cb3711 Provide definition of alloca() in mpconfigport.h. 2014-06-08 13:25:33 +01:00
Damien George df896eceef Merge branch 'alloca' of github.com:marcusva/micropython into marcusva-alloca 2014-06-08 13:18:14 +01:00
Paul Sokolovsky b9b9354e6c modsys: Add optional support for sys.platform.
Ports which wants to have it, should define MICROPY_PY_SYS_PLATFORM to a
string value they need.
2014-06-07 23:40:04 +03:00
Damien George a9b5248e18 Merge pull request #672 from marcusva/makefile
toolchain fixes to enable cross compatibility
2014-06-07 13:03:29 +01:00
Marcus von Appen 585a3394df - Cast the struct stat sb.st_ino field to machine_int_t explicitly to avoid a
cast error in MP_OBJ_NEW_SMALL_INT(). This is necessary for FreeBSD, where
  st_ino is of different size
- If MP_CLOCKS_PER_SEC is defined on the target host, simply define CLOCK_DIV
  as a fraction, regardless of the value of MP_CLOCKS_PER_SEC.
  FreeBSD uses a non-POSIX compliant value of 128 for CLOCKS_PER_SEC
2014-06-07 09:50:18 +02:00
Marcus von Appen 0c90eb1658 - FreeBSD provides alloca() via stdlib.h, in contrast to Linux and Windows
- Move the includes for alloca() intp mpconfigport.h
2014-06-07 09:36:04 +02:00
Marcus von Appen 8ffc02495f - Let the build environment decide about the toolchain to be used, in case
there are special tweaks and paths to be considered. Just provide some
  defaults, in case the values are undefined.
- py-version.sh does not need any bash specific features.
- Use libdl only on Linux for now. FreeBSD provides dl*() calls from libc.
2014-06-07 09:16:42 +02:00
Damien George c61be8e1e1 Merge pull request #662 from stinos/windows-pathsep
unix: Fix path seperator used depending on OS
2014-06-07 00:05:59 +01:00
Paul Sokolovsky 755a55f507 modgc: Implement return value for gc.collect(), enable on Unix. 2014-06-05 22:48:02 +03:00
stijn df3ab07994 unix: Fix path seperator used depending on OS
';' is the standard seperator used for paths in environment variables on Windows
2014-06-05 12:34:41 +02:00
Paul Sokolovsky 76c8a4c91b unix: Add setjmp-based GC register helper implementation.
As I suspected for a long time, for x86, register helper doesn't really make
any difference - there's simply not enough register to keep anything in
them for any prolonged time. Anything gets pushed on stack anyway. So, on
x86, uPy passed all tests even with empty reg helper. So, this setjmp
implementation goes as "untested".
2014-06-05 04:32:17 +03:00
Paul Sokolovsky d3439d0c60 py: Instead of having "debug on" var, have "optimization level" var.
This allows to have multiple "optimization" levels (CPython has two
(-OO removes docstrings), we can have more).
2014-06-03 12:32:59 +03:00