Commit Graph

5499 Commits

Author SHA1 Message Date
Paul Sokolovsky ee1656e148 extmod/moduhashlib: Add support for SHA1 (based on axTLS).
SHA1 is used in a number of protocols and algorithm originated 5 years ago
or so, in other words, it's in "wide use", and only newer protocols use
SHA2.

The implementation depends on axTLS enabled. TODO: Make separate config
option specifically for sha1().
2016-01-24 20:55:09 +02:00
Damien George df4ce930e3 py/modmicropython: Add stack_use, heap_lock and heap_unlock functions.
micropython.stack_use() returns an integer being the number of bytes used
on the stack.

micropython.heap_lock() and heap_unlock() can be used to prevent the
memory manager from allocating anything on the heap.  Calls to these are
allowed to be nested.
2016-01-24 09:12:06 +00:00
Dave Hylands 42a6364a31 stmhal: Add support for building frozen files.
This allows FROZEN_DIR=some-directory to be specified on the make
command line, which will then add all of the files contained within
the indicated frozen directory as frozen files in the image.

There is no change in flash/ram usage if not using the feature.

This is especially useful on smaller MCUs (like the 401) which only
has 64K flash file system.
2016-01-23 21:53:04 +00:00
Paul Sokolovsky 6c8b3a7fee py/objgetitemiter: Typo fix in comment. 2016-01-23 23:30:06 +02:00
Paul Sokolovsky cb4fbc8861 unix/modsocket: accept(): Make IPv6-clean.
By reserving enough space for peer address.
2016-01-21 23:55:20 +02:00
Dave Hylands f22844b4e5 stmhal: Add os.statvfs
Implement enough of statvfs to determine the amount of free
space on a volume.
2016-01-19 12:29:47 +00:00
Dave Hylands a17755ee8b py: Add ustruct.pack_into and unpack_from 2016-01-19 12:25:28 +00:00
Paul Sokolovsky ac16cc9a35 .travis.yml: Switch to Ubuntu 14.04 Trusty.
This allows to cut number of packages installed from 3rd-party package repos,
and otherwise cut number of overrides and hacks.
2016-01-17 20:07:41 +02:00
Paul Sokolovsky ea495d6aa6 extmod/modurandom: Make yasmarang() function static. 2016-01-17 14:12:33 +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 e7bee6b35e pic16bit: Minor updates to types to allow port to compile again. 2016-01-16 21:07:26 +00:00
Damien George 31dd312f83 unix/modffi: Allow to compile modffi in OBJ_REPR_D mode. 2016-01-15 14:26:24 +00:00
Damien George 55ad083061 unix/.gitignore: Add nanbox build output to ignore list. 2016-01-15 14:25:53 +00:00
Damien George aeadda4eac travis: Add unix NaN-boxing build to Travis builds.
This will help make sure new commits work with OBJ_REPR_D.
2016-01-15 11:13:42 +00: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
Damien George ff133cdb07 py/objproperty: Fix static struct to build with OBJ_REPR_D. 2016-01-15 11:09:20 +00:00
chrysn f8ba2eca80 builtin property: accept keyword arguments
this allows python code to use property(lambda:..., doc=...) idiom.

named versions for the fget, fset and fdel arguments are left out in the
interest of saving space; they are rarely used and easy to enable when
actually needed.

a test case is included.
2016-01-14 21:15:18 +02:00
stijn dea585f8ae tests: Remove builtin_dict test
This is essentially a duplicate of obj_dict.py
2016-01-14 21:10:59 +02:00
Peter Hinch c13b2f2d00 docs: Several minor changes: network, pyb, ADCAll and inline asm. 2016-01-13 21:53:26 +00:00
Damien George 22d85ec5be py: Use new code pattern for parsing kw args with mp_arg_parse_all.
Makes code easier to read and more maintainable.
2016-01-13 15:47:56 +00:00
Damien George 8bb4931fec py/emitglue: Use mp_obj_is_float instead of MP_OBJ_IS_TYPE. 2016-01-13 15:24:41 +00:00
Antonin ENFRUN efc971e8f9 py: unary_op enum type fix, and a cast to remove clang warning 2016-01-12 22:06:39 +01:00
Damien George c9845a0685 unix: Allow to build coverage build with OBJ_REPR_D. 2016-01-11 16:30:58 +00:00
Dave Hylands 11b97d7ec5 unix: Add socket.inet_ntop function 2016-01-11 12:08:07 +02:00
Damien George 5b3f0b7f39 py: Change first arg of type.make_new from mp_obj_t to mp_obj_type_t*.
The first argument to the type.make_new method is naturally a uPy type,
and all uses of this argument cast it directly to a pointer to a type
structure.  So it makes sense to just have it a pointer to a type from
the very beginning (and a const pointer at that).  This patch makes
such a change, and removes all unnecessary casting to/from mp_obj_t.
2016-01-11 00:49:27 +00:00
Damien George 4b72b3a133 py: Change type signature of builtin funs that take variable or kw args.
With this patch the n_args parameter is changed type from mp_uint_t to
size_t.
2016-01-11 00:49:27 +00:00
Damien George a0c97814df py: Change type of .make_new and .call args: mp_uint_t becomes size_t.
This patch changes the type signature of .make_new and .call object method
slots to use size_t for n_args and n_kw (was mp_uint_t.  Makes code more
efficient when mp_uint_t is larger than a machine word.  Doesn't affect
ports when size_t and mp_uint_t have the same size.
2016-01-11 00:48:41 +00:00
Dave Hylands 66d0c1052a extmod: Fix uctypes size calculation for bitfields 2016-01-10 23:31:26 +02:00
Paul Sokolovsky 8175877ad6 unix/modtime: strftime(): Support 2nd argument, but as time_t value.
Instead of struct tm like structure, as required by CPython.
2016-01-10 12:08:27 +02:00
Damien George fe6756aa2d py: Remove long-obsolete mp_method_t typedef. 2016-01-10 00:06:36 +00:00
Paul Sokolovsky bae052d420 examples/unix: Rename example be importable as modules.
Replace hyphens with undescores in modules.
2016-01-09 12:04:25 +02:00
Damien George 3b936a5f4c tests: Fix math_fun_special test so it passes with single prec float. 2016-01-08 17:58:02 +00:00
Damien George da3dffa79d py/objint: Fix classification of float so it works for OBJ_REPR_D. 2016-01-08 17:57:30 +00:00
Damien George 2adf7ec3dd py/mpz: Fix conversion of float to mpz so it works on big endian archs. 2016-01-08 17:56:58 +00:00
Damien George b1fa907d56 tests: Allow float tests to run when MATH_SPECIAL_FUNCTIONS is disabled. 2016-01-08 14:27:21 +00:00
Damien George 978d2e55ef py/runtime: Use appropriate printf fmt for malloc num_bytes. 2016-01-08 13:49:58 +00:00
Damien George c1c57eafac py/smallint: Allow to override MP_SMALL_INT_MIN et al.
This allows a port to specify exactly how many bits are in a small
int (eg for a uPy bytecode cross compiler).
2016-01-08 13:43:56 +00:00
Damien George 1fa6be5264 py/obj: For OBJ_REPR_D, use uint32_t cast when extracting qstr value. 2016-01-08 13:43:13 +00:00
Damien George 7dbf74c5b9 py/parse: Include unistd.h for ssize_t definition.
In some cases ssize_t is not defined by already included headers.
2016-01-08 13:42:00 +00:00
Damien George 1404d620c0 py/emitglue: Add more feature flags to .mpy persistent bytecode output.
Need to record in .mpy file whether unicode is enabled, and how many bits
are in a small int.
2016-01-08 13:35:35 +00:00
Paul Sokolovsky adfe4ff72a esp8266: Support CFLAGS_EXTRA. 2016-01-08 01:30:20 +02:00
Damien George 54729247e1 minimal: Add enough code to run minimal build on STM32F4xx hardware.
Minimal support code for a Cortex-M CPU is added, along with set-up
code for an STM32F4xx MCU, including a UART for a REPL.  Tested on
a pyboard.  Code size is 77592 bytes.
2016-01-07 17:43:07 +00:00
Damien George dd0a0f79d7 py/viper: Truncate viper integer args so they can be up to 32-bit. 2016-01-07 16:48:20 +00:00
Damien George daa1a455c6 stmhal: Remove custom mod_machine_mem_get_{read,write}_addr functions.
They are no longer needed because stm constants can now be 32 bits wide.
2016-01-07 16:34:11 +00:00
Damien George 2621f8a340 stmhal: Make stm constants big ints when they don't fit in a small int.
Adds 924 bytes of code, but means that no more hacks and work-arounds are
needed due to large constants becoming negative.
2016-01-07 16:34:11 +00:00
Damien George ea8be373a9 py/inlinethumb: Remove 30-bit restriction on movwt instruction.
movwt can now move a full 32-bit constant into a register.
2016-01-07 16:34:11 +00:00
Damien George 47dc5922ca py/inlinethumb: Allow assembler to use big ints as args to instructions. 2016-01-07 16:21:07 +00:00
Damien George 22b2265053 py/parse: Improve constant folding to operate on small and big ints.
Constant folding in the parser can now operate on big ints, whatever
their representation.  This is now possible because the parser can create
parse nodes holding arbitrary objects.  For the case of small ints the
folding is still efficient in RAM because the folded small int is stored
inplace in the parse node.

Adds 48 bytes to code size on Thumb2 architecture.  Helps reduce heap
usage because more constants can be computed at compile time, leading to
a smaller parse tree, and most importantly means that the constants don't
have to be computed at runtime (perhaps more than once).  Parser will now
be a little slower when folding due to calls to runtime to do the
arithmetic.
2016-01-07 14:40:35 +00:00
Damien George d6b31e4578 py: Change mp_obj_int_is_positive to more general mp_obj_int_sign.
This function returns the sign (-1, 0 or 1) of the integer object.
2016-01-07 14:29:12 +00:00
Damien George 93b3726240 py/parse: Optimise away parse node that's just parenthesis around expr.
Before this patch, (x+y)*z would be parsed to a tree that contained a
redundant identity parse node corresponding to the parenthesis.  With
this patch such nodes are optimised away, which reduces memory
requirements for expressions with parenthesis, and simplifies the
compiler because it doesn't need to handle this identity case.

A parenthesis parse node is still needed for tuples.
2016-01-07 13:07:52 +00:00