Wykres commitów

166 Commity (13f7a7b86b52e3db3ab5968503eae5cf57f13004)

Autor SHA1 Wiadomość Data
Paul Sokolovsky e381efed4a unix/modtime: Use ticks_diff() implementation from extmod/utime_mphal.c. 2016-10-29 04:58:06 +03:00
Paul Sokolovsky c428367543 extmod/modubinascii: Make crc32() support configurable.
Disable by default, enable in unix port.
2016-08-24 18:28:43 +03: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
ilovezfs 4e36dd570b unix/mpconfigport.h: Don't include stdio.h on MacOS.
Fixes build errors such as
"../lib/utils/printf.c:43:5: error: expected parameter declarator"
2016-08-10 21:43:34 +03:00
Paul Sokolovsky 56eb25f049 py/objstr: Make .partition()/.rpartition() methods configurable.
Default is disabled, enabled for unix port. Saves 600 bytes on x86.
2016-08-07 06:46:55 +03:00
Paul Sokolovsky 5b9e7e29f6 unix: Enable websocket module. 2016-08-06 15:15:53 +03:00
Paul Sokolovsky 61e77a4e88 py/mpconfig.h: Add MICROPY_STREAMS_POSIX_API setting.
To filter out even prototypes of mp_stream_posix_*() functions, which
require POSIX types like ssize_t & off_t, which may be not available in
some ports.
2016-07-30 20:05:56 +03:00
Paul Sokolovsky 243f8988be unix/mpconfigport.h: Include stdio.h by default.
This allows to use printf() in a any source file with unix port, for quick
debugging.
2016-07-26 02:51:25 +03:00
Paul Sokolovsky 918851e836 unix: Enable MICROPY_PY_STR_BYTES_CMP_WARN.
Also, fix a warning text (remove "duplicate" BytesWarning).
2016-07-22 00:52:07 +03:00
Paul Sokolovsky 20283aec10 extmod/modussl_axtls: Further changes to allow alternative SSL modules.
Make variable MICROPY_SSL_AXTLS=1 should be defined to activate modussl_axtls
and link with -laxtls.
2016-07-13 01:49:38 +03:00
Paul Sokolovsky e68811dbbf unix/modmachine: Enable time_pulse_us() function. 2016-06-19 00:21:17 +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 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 6f8880d0ab unix: Move "utime" module config to C level instead of make level. 2016-06-17 23:35:00 +03:00
Paul Sokolovsky 0f5bf1aafe py/mpconfig.h: MP_NOINLINE is universally useful, move from unix port. 2016-06-15 23:52:00 +03:00
Paul Sokolovsky 1b5abfcaae py/objstr: Implement str.center().
Disabled by default, enabled in unix port. Need for this method easily
pops up when working with text UI/reporting, and coding workalike
manually again and again counter-productive.
2016-05-22 00:13:44 +03:00
Damien George 1e024de7be unix: Add ability to include frozen bytecode in the build.
To use frozen bytecode make a subdirectory under the unix/ directory
(eg frozen/), put .py files there, then run:

    make FROZEN_MPY_DIR=frozen

Be sure to build from scratch.  The .py files will then be available for
importing.
2016-05-16 23:17:11 +01:00
Damien George 088127d91c unix: Enable uerrno module. 2016-05-10 23:30:39 +01: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 47442d9f52 lib/utils/printf: Rework overriding printer of DEBUG_printf().
By default it uses mp_plat_print, but a port may override it to another
value with MICROPY_DEBUG_PRINTER_DEST.
2016-04-13 11:53:12 +03:00
Paul Sokolovsky 1a327c4fa3 unix: Build with MICROPY_PY_UHASHLIB_SHA1 if already building with axTLS. 2016-04-11 21:58:58 +03:00
Damien George ac23662550 unix: Enabled importing of persistent bytecode (.mpy files). 2016-02-25 10:12:30 +00:00
Paul Sokolovsky 72085a669b py/mpstate.h: fs_user_mount is now standard, reusable uPy functionality. 2016-02-15 00:02:03 +02:00
Paul Sokolovsky 8a43a41b3a unix: Enable VfsFat support. 2016-02-14 19:15:22 +02: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
Paul Sokolovsky a58a91eb04 extmod/modurandom: Add "urandom" module.
Seedable and reproducible pseudo-random number generator. Implemented
functions are getrandbits(n) (n <= 32) and seed().

The algorithm used is Yasmarang by Ilya Levin:
http://www.literatecode.com/yasmarang
2016-01-17 12:13:01 +02:00
Damien George d8b08cf5fc unix: Add option to build 64-bit NaN-boxing interpreter.
Build using: make nanbox
2016-01-15 11:12:08 +00:00
Paul Sokolovsky 30b7344eb0 extmod/moduos_dupterm: Make mp_uos_dupterm_tx_strn() function reusable.
Function to actually spool output terminal data to dupterm object.
2016-01-01 16:43:35 +02:00
Paul Sokolovsky 00ee84e1e1 py: Clean up instantiation of dupterm object.
To comply with already established scheme for extmod's.
2016-01-01 14:22:57 +02:00
Paul Sokolovsky 9bbfd5efd4 py/mpconfig: Make configuration of dupterm object reusable. 2016-01-01 13:16:18 +02:00
Paul Sokolovsky 2c1620ce1f unix: Implement uos.dupterm(). Conditional on MICROPY_PY_OS_DUPTERM. 2015-12-28 01:13:21 +02:00
Paul Sokolovsky 1c9210bc2b unix/unix_mphal: Raise KeyboardInterrupt straight from signal handler.
POSIX doesn't guarantee something like that to work, but it works on any
system with careful signal implementation. Roughly, the requirement is
that signal handler is executed in the context of the process, its main
thread, etc. This is true for Linux. Also tested to work without issues
on MacOSX.
2015-12-23 00:07:00 +02:00
Dave Hylands 755b01439b unix: machine_mem improvements
This basically introduces the MICROPY_MACHINE_MEM_GET_READ_ADDR
and MICROPY_MACHINE_MEM_GET_WRITE_ADDR macros. If one of them is
not defined, then a default identity function is provided.
2015-12-18 22:01:03 +02:00
Paul Sokolovsky 2eb844e0b4 ports: Rename "machine" module to "umachine".
To let unix port implement "machine" functionality on Python level, and
keep consistent naming in other ports (baremetal ports will use magic
module "symlinking" to still load it on "import machine").

Fixes #1701.
2015-12-18 02:39:52 +02:00
Damien George 0d7de08e06 unix: Change define logic of _DIRENT_HAVE_D_INO to match other macros. 2015-12-16 14:17:56 +00:00
Paul Sokolovsky d874702fe1 unix/modos: Implement ilistdir().
ilistdir() returns iterator which yields triples of (name, type, ino)
where ino is inode number for entry's data, type of entry (file/dir/etc.),
and name of file/dir. listdir() can be easily implemented in terms of this
iterator (which is otherwise more efficient in terms of memory use and may
save expensive call to stat() for each returned entry).

CPython has os.scandir() which also returns an iterator, but it yields
more complex objects of DirEntry type. scandir() can also be easily
implemented in terms of ilistdir().
2015-12-14 23:48:12 +02:00
Paul Sokolovsky 2d11b17419 unix/moduselect: Make configurable with MICROPY_PY_USELECT. 2015-12-13 08:47:42 +02:00
Dave Hylands f925165942 unix: Move modmachine into unix directory
This leaves behind the common functionality in extmod/machine_mem.c
which can be used by all ports.
2015-12-13 01:21:36 +02:00
Paul Sokolovsky a6eff059b9 unix: Rename "_os" module to "uos" for consistency with baremetal ports. 2015-12-12 00:04:35 +02:00
Paul Sokolovsky 30d0cf4885 unix/mpconfigport: Typo fix in comment. 2015-12-03 01:41:26 +02:00
Paul Sokolovsky d735278c9f unix/mpconfigport.h: For MICROPY_NO_ALLOCA=1, don't even include alloca.h. 2015-12-02 16:05:02 +02:00
Damien George cbf7674025 py: Add MP_ROM_* macros and mp_rom_* types and use them. 2015-11-29 14:25:04 +00:00
Paul Sokolovsky 0bb57bf5bf unix/modtime: sleep(): Automatically restart after receiving EINTR.
THis is required to deal well with signals, signals being the closest
analogue of hardware interrupts for POSIX. This is also CPython 3.5
compliant behavior (PEP 475).

The main problem implementing this is to figure out how much time was
spent in waiting so far/how much is remaining. It's well-known fact that
Linux updates select()'s timeout value when returning with EINTR to the
remaining wait time. Here's what POSIX-based standards say about this:
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/pselect.html):

"Upon successful completion, the select() function may modify the object
pointed to by the timeout argument."

I.e. it allows to modify timeout value, but doesn't say how exactly it is
modified. And actually, it allows such modification only "upon successful
completion", which returning with EINTR error hardly is.

POSIX also allows to request automatic EINTR restart for system calls using
sigaction call with SA_RESTART flag, but here's what the same document says
about it:

"If SA_RESTART has been set for the interrupting signal, it is
implementation-defined whether the function restarts or returns with
[EINTR]."

In other words, POSIX doesn't leave room for both portable and efficient
handling of this matter, so the code just allows to manually select
Linux-compatible behavior with MICROPY_SELECT_REMAINING_TIME option,
or otherwise will just raise OSError. When systems with non-Linux behavior
are found, they can be handled separately.
2015-11-29 14:21:06 +02:00
Paul Sokolovsky c3280d83e7 unix: Use printf() implementation in terms of mp_printf().
In other words, unix port now uses overriden printf(), instead of using
libc's. This should remove almost all dependency on libc stdio (which
is bloated).
2015-11-22 00:44:41 +02:00
Paul Sokolovsky 65971f5160 unix: Add "uselect" module, with poll() function.
Underlyingly, uses standard POSIX poll() for portability.
2015-11-17 00:35:57 +02:00
Paul Sokolovsky 66fd3e4a7b unix: Use standard mphalport.h header.
This also unbreaks "make minimal".
2015-11-13 15:44:26 +02:00
Paul Sokolovsky 94f9330d3e unix: Allow to override MICROPY_PY_MATH_SPECIAL_FUNCTIONS from command-line. 2015-11-13 15:24:57 +02:00
Paul Sokolovsky 6d1eabfeaa unix/mpconfigport: Move log2() definition to modmath.c.
It's safer to define it where it's used, defining it for all source files
may lead to hard to diagnose conflicts in corner cases.
2015-11-13 15:24:48 +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