diff options
author | Damien George <damien.p.george@gmail.com> | 2014-03-17 10:31:03 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-03-17 10:31:03 +0000 |
commit | c44115f831046b832dffdd0f7ab9acee89c69251 (patch) | |
tree | b6d47715a189326e3cf9bc951be06ddf2825d61e /py | |
parent | 781687c77280c96b4b240994a0a0e28cc959d269 (diff) | |
parent | c55388823f355334b1691b97cad5efc279feb224 (diff) | |
download | micropython-c44115f831046b832dffdd0f7ab9acee89c69251.tar.gz micropython-c44115f831046b832dffdd0f7ab9acee89c69251.zip |
Merge branch 'master' of github.com:xbe/micropython
Diffstat (limited to 'py')
58 files changed, 27 insertions, 119 deletions
diff --git a/py/asmthumb.c b/py/asmthumb.c index 1e6c23e2ee..3fcd28a91d 100644 --- a/py/asmthumb.c +++ b/py/asmthumb.c @@ -1,4 +1,3 @@ -#include <stdint.h> #include <stdio.h> #include <assert.h> #include <string.h> diff --git a/py/binary.c b/py/binary.c index 20b38b8b14..7a8ed46111 100644 --- a/py/binary.c +++ b/py/binary.c @@ -1,4 +1,3 @@ -#include <stdlib.h> #include <stdint.h> #include <assert.h> diff --git a/py/builtin.c b/py/builtin.c index df488e054a..2e0627fa5f 100644 --- a/py/builtin.c +++ b/py/builtin.c @@ -1,8 +1,4 @@ -#include <stdint.h> -#include <stdlib.h> #include <stdio.h> -#include <stdarg.h> -#include <string.h> #include <assert.h> #include "nlr.h" diff --git a/py/builtinevex.c b/py/builtinevex.c index 6e920e85f0..d658db0adf 100644 --- a/py/builtinevex.c +++ b/py/builtinevex.c @@ -1,9 +1,4 @@ #include <stdint.h> -#include <stdlib.h> -#include <stdio.h> -#include <stdarg.h> -#include <string.h> -#include <assert.h> #include "nlr.h" #include "misc.h" diff --git a/py/builtinimport.c b/py/builtinimport.c index 7cbb46012b..2b9b3a30b9 100644 --- a/py/builtinimport.c +++ b/py/builtinimport.c @@ -1,7 +1,6 @@ #include <stdint.h> #include <stdlib.h> #include <stdio.h> -#include <stdarg.h> #include <string.h> #include <assert.h> diff --git a/py/builtinmath.c b/py/builtinmath.c index 35c1e45edc..eeb715048a 100644 --- a/py/builtinmath.c +++ b/py/builtinmath.c @@ -1,4 +1,3 @@ -#include <stdint.h> #include <math.h> #include "misc.h" diff --git a/py/builtinmp.c b/py/builtinmp.c index 22091f4ea5..3b73517963 100644 --- a/py/builtinmp.c +++ b/py/builtinmp.c @@ -1,4 +1,3 @@ -#include <stdint.h> #include "misc.h" #include "mpconfig.h" diff --git a/py/compile.c b/py/compile.c index d1aec30958..bb688d5d8e 100644 --- a/py/compile.c +++ b/py/compile.c @@ -1,5 +1,4 @@ -#include <unistd.h> -#include <stdlib.h> +#include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <string.h> diff --git a/py/emitbc.c b/py/emitbc.c index b26da0e706..ef5da3a622 100644 --- a/py/emitbc.c +++ b/py/emitbc.c @@ -1,5 +1,4 @@ -#include <unistd.h> -#include <stdlib.h> +#include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <string.h> diff --git a/py/emitcommon.c b/py/emitcommon.c index ff6457289a..f7494668e0 100644 --- a/py/emitcommon.c +++ b/py/emitcommon.c @@ -1,7 +1,5 @@ #include <unistd.h> -#include <stdio.h> #include <stdint.h> -#include <string.h> #include <assert.h> #include "misc.h" diff --git a/py/emitcpy.c b/py/emitcpy.c index b31425f2ec..afd5a5af94 100644 --- a/py/emitcpy.c +++ b/py/emitcpy.c @@ -1,5 +1,4 @@ -#include <unistd.h> -#include <stdlib.h> +#include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <string.h> diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c index 675ed1efc8..55af97f835 100644 --- a/py/emitinlinethumb.c +++ b/py/emitinlinethumb.c @@ -1,5 +1,3 @@ -#include <unistd.h> -#include <stdlib.h> #include <stdint.h> #include <stdio.h> #include <string.h> diff --git a/py/emitnative.c b/py/emitnative.c index df531af6b1..3ed415b04c 100644 --- a/py/emitnative.c +++ b/py/emitnative.c @@ -16,8 +16,7 @@ // for x in l[0:8]: can be compiled into a native loop if l has pointer type -#include <unistd.h> -#include <stdlib.h> +#include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <string.h> diff --git a/py/emitpass1.c b/py/emitpass1.c index d492652399..e4dbf14121 100644 --- a/py/emitpass1.c +++ b/py/emitpass1.c @@ -1,8 +1,5 @@ -#include <unistd.h> #include <stdlib.h> #include <stdint.h> -#include <stdio.h> -#include <string.h> #include <assert.h> #include "misc.h" diff --git a/py/formatfloat.c b/py/formatfloat.c index e42266a714..83aee1ef74 100644 --- a/py/formatfloat.c +++ b/py/formatfloat.c @@ -13,7 +13,6 @@ ***********************************************************************/ -#include <stdint.h> #include <stdlib.h> #include "mpconfig.h" @@ -1,6 +1,5 @@ #include <stdio.h> #include <stdlib.h> -#include <stdint.h> #include <string.h> #include "mpconfig.h" diff --git a/py/lexer.c b/py/lexer.c index 26fec121c1..58d54b6980 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -1,9 +1,9 @@ /* lexer.c -- simple tokeniser for Python implementation */ +#include <stdbool.h> #include <stdint.h> #include <stdio.h> -#include <string.h> #include <assert.h> #include "misc.h" diff --git a/py/lexerstr.c b/py/lexerstr.c index 634aa42acd..a2168c96c1 100644 --- a/py/lexerstr.c +++ b/py/lexerstr.c @@ -1,5 +1,3 @@ -#include <stdint.h> -#include <stdio.h> #include "misc.h" #include "mpconfig.h" diff --git a/py/lexerunix.c b/py/lexerunix.c index fb62d3d72f..73d30f2476 100644 --- a/py/lexerunix.c +++ b/py/lexerunix.c @@ -1,4 +1,3 @@ -#include <stdint.h> #include <stdio.h> #include <unistd.h> #include <fcntl.h> @@ -11,6 +10,9 @@ #if MICROPY_ENABLE_LEXER_UNIX +#include <sys/stat.h> +#include <sys/types.h> + mp_lexer_t *mp_lexer_new_from_file(const char *filename) { int fd = open(filename, O_RDONLY); if (fd < 0) { diff --git a/py/malloc.c b/py/malloc.c index 27eaac1088..504db4b1b9 100644 --- a/py/malloc.c +++ b/py/malloc.c @@ -1,3 +1,4 @@ +#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -1,6 +1,4 @@ -#include <stdint.h> #include <stdlib.h> -#include <assert.h> #include "misc.h" #include "mpconfig.h" @@ -1,8 +1,5 @@ -#include <stdint.h> -#include <stdlib.h> #include <stdio.h> #include <stdarg.h> -#include <string.h> #include <assert.h> #include "nlr.h" diff --git a/py/objarray.c b/py/objarray.c index d0b3e003b8..ee43bde960 100644 --- a/py/objarray.c +++ b/py/objarray.c @@ -1,7 +1,4 @@ -#include <stdlib.h> -#include <stdint.h> #include <string.h> -#include <stdarg.h> #include <assert.h> #include "nlr.h" diff --git a/py/objbool.c b/py/objbool.c index 1dc5e5760e..9b4af2a31d 100644 --- a/py/objbool.c +++ b/py/objbool.c @@ -1,5 +1,3 @@ -#include <stdlib.h> -#include <stdint.h> #include "nlr.h" #include "misc.h" diff --git a/py/objboundmeth.c b/py/objboundmeth.c index 0b5fc10a07..1b9ac61f24 100644 --- a/py/objboundmeth.c +++ b/py/objboundmeth.c @@ -1,7 +1,4 @@ -#include <stdlib.h> -#include <stdlib.h> #include <string.h> -#include <assert.h> #include "nlr.h" #include "misc.h" diff --git a/py/objcell.c b/py/objcell.c index 3666617474..a6922b018a 100644 --- a/py/objcell.c +++ b/py/objcell.c @@ -1,6 +1,3 @@ -#include <stdlib.h> -#include <stdint.h> -#include <assert.h> #include "nlr.h" #include "misc.h" diff --git a/py/objclosure.c b/py/objclosure.c index e2de0e0451..cd8129e24f 100644 --- a/py/objclosure.c +++ b/py/objclosure.c @@ -1,7 +1,4 @@ -#include <stdlib.h> -#include <stdint.h> #include <string.h> -#include <assert.h> #include "nlr.h" #include "misc.h" diff --git a/py/objcomplex.c b/py/objcomplex.c index bba89daf00..65957cbf60 100644 --- a/py/objcomplex.c +++ b/py/objcomplex.c @@ -1,6 +1,4 @@ #include <stdlib.h> -#include <stdint.h> -#include <string.h> #include <assert.h> #include "nlr.h" diff --git a/py/objdict.c b/py/objdict.c index 31a80bd6cb..17cc499c5e 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -1,5 +1,4 @@ -#include <stdlib.h> -#include <stdint.h> +#include <stdbool.h> #include <string.h> #include <assert.h> diff --git a/py/objenumerate.c b/py/objenumerate.c index 1c858ff56f..1862eb74e1 100644 --- a/py/objenumerate.c +++ b/py/objenumerate.c @@ -1,4 +1,3 @@ -#include <stdlib.h> #include <assert.h> #include "misc.h" diff --git a/py/objexcept.c b/py/objexcept.c index 532ca4320a..11177724da 100644 --- a/py/objexcept.c +++ b/py/objexcept.c @@ -1,5 +1,3 @@ -#include <stdlib.h> -#include <stdint.h> #include <string.h> #include <stdarg.h> #include <assert.h> diff --git a/py/objfilter.c b/py/objfilter.c index dc400f1a2f..ea76b99070 100644 --- a/py/objfilter.c +++ b/py/objfilter.c @@ -1,4 +1,3 @@ -#include <stdlib.h> #include <assert.h> #include "nlr.h" diff --git a/py/objfloat.c b/py/objfloat.c index 04d1278014..401c1145ee 100644 --- a/py/objfloat.c +++ b/py/objfloat.c @@ -1,6 +1,4 @@ #include <stdlib.h> -#include <stdint.h> -#include <string.h> #include <assert.h> #include "nlr.h" diff --git a/py/objfun.c b/py/objfun.c index 361df19145..7d49f18da4 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -1,5 +1,5 @@ +#include <stdbool.h> #include <stdlib.h> -#include <stdint.h> #include <string.h> #include <assert.h> diff --git a/py/objgenerator.c b/py/objgenerator.c index 6a03af856b..8c4bb595f1 100644 --- a/py/objgenerator.c +++ b/py/objgenerator.c @@ -1,6 +1,4 @@ #include <stdlib.h> -#include <stdint.h> -#include <string.h> #include <assert.h> #include "nlr.h" diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c index bf466c05d9..08ef66f29f 100644 --- a/py/objgetitemiter.c +++ b/py/objgetitemiter.c @@ -1,5 +1,3 @@ -#include <stdlib.h> -#include <stdint.h> #include "nlr.h" #include "misc.h" diff --git a/py/objint.c b/py/objint.c index 7a9b0366db..9cba1ce744 100644 --- a/py/objint.c +++ b/py/objint.c @@ -1,6 +1,4 @@ -#include <stdlib.h> #include <stdint.h> -#include <string.h> #include <assert.h> #include "nlr.h" diff --git a/py/objint_longlong.c b/py/objint_longlong.c index eca2951be6..58c2466fd0 100644 --- a/py/objint_longlong.c +++ b/py/objint_longlong.c @@ -1,7 +1,5 @@ #include <stdlib.h> #include <stdint.h> -#include <string.h> -#include <assert.h> #include "nlr.h" #include "misc.h" diff --git a/py/objint_mpz.c b/py/objint_mpz.c index e8e8b85472..8b7ed78a2c 100644 --- a/py/objint_mpz.c +++ b/py/objint_mpz.c @@ -1,7 +1,5 @@ -#include <stdlib.h> #include <stdint.h> #include <string.h> -#include <assert.h> #include "nlr.h" #include "misc.h" diff --git a/py/objlist.c b/py/objlist.c index aa082ea34b..f43670d603 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -1,5 +1,3 @@ -#include <stdlib.h> -#include <stdint.h> #include <string.h> #include <assert.h> diff --git a/py/objmap.c b/py/objmap.c index cbaef6fb9a..2b356ec4ea 100644 --- a/py/objmap.c +++ b/py/objmap.c @@ -1,4 +1,3 @@ -#include <stdlib.h> #include <assert.h> #include "nlr.h" diff --git a/py/objmodule.c b/py/objmodule.c index 791932dc7f..e0778b4cf2 100644 --- a/py/objmodule.c +++ b/py/objmodule.c @@ -1,6 +1,4 @@ #include <stdlib.h> -#include <stdint.h> -#include <string.h> #include <assert.h> #include "nlr.h" diff --git a/py/objnone.c b/py/objnone.c index 489d34d138..a4370efebc 100644 --- a/py/objnone.c +++ b/py/objnone.c @@ -1,5 +1,4 @@ #include <stdlib.h> -#include <stdint.h> #include "nlr.h" #include "misc.h" diff --git a/py/objrange.c b/py/objrange.c index 80c5928385..f80bc08602 100644 --- a/py/objrange.c +++ b/py/objrange.c @@ -1,5 +1,3 @@ -#include <stdlib.h> -#include <stdint.h> #include "nlr.h" #include "misc.h" diff --git a/py/objset.c b/py/objset.c index aea107fc1c..437bae9bf8 100644 --- a/py/objset.c +++ b/py/objset.c @@ -1,5 +1,4 @@ -#include <stdlib.h> -#include <stdint.h> +#include <stdbool.h> #include <string.h> #include <assert.h> diff --git a/py/objslice.c b/py/objslice.c index 10df671fea..46cce264a9 100644 --- a/py/objslice.c +++ b/py/objslice.c @@ -1,6 +1,4 @@ #include <stdlib.h> -#include <stdint.h> -#include <string.h> #include <assert.h> #include "nlr.h" diff --git a/py/objstr.c b/py/objstr.c index 64ba6c5fad..d660bf952b 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -1,6 +1,4 @@ -#include <stdlib.h> -#include <stdint.h> -#include <stdarg.h> +#include <stdbool.h> #include <string.h> #include <assert.h> @@ -286,8 +284,8 @@ STATIC mp_obj_t str_find(uint n_args, const mp_obj_t *args) { GET_STR_DATA_LEN(args[0], haystack, haystack_len); GET_STR_DATA_LEN(args[1], needle, needle_len); - size_t start = 0; - size_t end = haystack_len; + machine_uint_t start = 0; + machine_uint_t end = haystack_len; /* TODO use a non-exception-throwing mp_get_index */ if (n_args >= 3 && args[2] != mp_const_none) { start = mp_get_index(&str_type, haystack_len, args[2], true); @@ -320,8 +318,8 @@ STATIC mp_obj_t str_startswith(mp_obj_t self_in, mp_obj_t arg) { return MP_BOOL(memcmp(str, prefix, prefix_len) == 0); } -STATIC bool chr_in_str(const byte* const str, const size_t str_len, int c) { - for (size_t i = 0; i < str_len; i++) { +STATIC bool chr_in_str(const byte* const str, const machine_uint_t str_len, int c) { + for (machine_uint_t i = 0; i < str_len; i++) { if (str[i] == c) { return true; } @@ -349,10 +347,10 @@ STATIC mp_obj_t str_strip(uint n_args, const mp_obj_t *args) { GET_STR_DATA_LEN(args[0], orig_str, orig_str_len); - size_t first_good_char_pos = 0; + machine_uint_t first_good_char_pos = 0; bool first_good_char_pos_set = false; - size_t last_good_char_pos = 0; - for (size_t i = 0; i < orig_str_len; i++) { + machine_uint_t last_good_char_pos = 0; + for (machine_uint_t i = 0; i < orig_str_len; i++) { if (!chr_in_str(chars_to_del, chars_to_del_len, orig_str[i])) { last_good_char_pos = i; if (!first_good_char_pos_set) { @@ -369,7 +367,7 @@ STATIC mp_obj_t str_strip(uint n_args, const mp_obj_t *args) { assert(last_good_char_pos >= first_good_char_pos); //+1 to accomodate the last character - size_t stripped_len = last_good_char_pos - first_good_char_pos + 1; + machine_uint_t stripped_len = last_good_char_pos - first_good_char_pos + 1; return mp_obj_new_str(orig_str + first_good_char_pos, stripped_len, false); } diff --git a/py/objtuple.c b/py/objtuple.c index 827441f704..83d1f21cea 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -1,6 +1,4 @@ #include <string.h> -#include <stdlib.h> -#include <stdint.h> #include <assert.h> #include "nlr.h" diff --git a/py/objtype.c b/py/objtype.c index 6480a99f6c..4898c5ccb4 100644 --- a/py/objtype.c +++ b/py/objtype.c @@ -1,5 +1,3 @@ -#include <stdlib.h> -#include <stdint.h> #include <string.h> #include <assert.h> diff --git a/py/parse.c b/py/parse.c index a7b73a5673..1381f1293d 100644 --- a/py/parse.c +++ b/py/parse.c @@ -1,9 +1,6 @@ -#include <unistd.h> -#include <stdlib.h> +#include <stdbool.h> #include <stdint.h> #include <stdio.h> -#include <ctype.h> -#include <string.h> #include <assert.h> #include "misc.h" diff --git a/py/parsenum.c b/py/parsenum.c index 8e290da338..c9cef5fcd8 100644 --- a/py/parsenum.c +++ b/py/parsenum.c @@ -1,3 +1,4 @@ +#include <stdbool.h> #include <stdlib.h> #include "misc.h" diff --git a/py/runtime.c b/py/runtime.c index bd6f2289de..9c8ba636c0 100644 --- a/py/runtime.c +++ b/py/runtime.c @@ -2,8 +2,6 @@ // mp_xxx functions are safer and can be called by anyone // note that rt_assign_xxx are called only from emit*, and maybe we can rename them to reflect this -#include <stdint.h> -#include <stdlib.h> #include <stdio.h> #include <string.h> #include <assert.h> diff --git a/py/scope.c b/py/scope.c index fc12fb5da0..cc4be7c85d 100644 --- a/py/scope.c +++ b/py/scope.c @@ -1,6 +1,6 @@ +#include <stdbool.h> #include <stdint.h> #include <stdio.h> -#include <string.h> #include <assert.h> #include "misc.h" diff --git a/py/sequence.c b/py/sequence.c index 1723bb416c..184c34e0b8 100644 --- a/py/sequence.c +++ b/py/sequence.c @@ -1,7 +1,5 @@ -#include <stdlib.h> -#include <stdint.h> +#include <stdbool.h> #include <string.h> -#include <assert.h> #include "nlr.h" #include "misc.h" diff --git a/py/showbc.c b/py/showbc.c index 609048e8f6..bc81086c7d 100644 --- a/py/showbc.c +++ b/py/showbc.c @@ -1,7 +1,4 @@ -#include <stdint.h> -#include <stdlib.h> #include <stdio.h> -#include <string.h> #include <assert.h> #include "misc.h" diff --git a/py/stream.c b/py/stream.c index 59877d7242..7c97ee10c3 100644 --- a/py/stream.c +++ b/py/stream.c @@ -1,4 +1,4 @@ -#include <string.h> +#include <unistd.h> #include "nlr.h" #include "misc.h" @@ -1,7 +1,4 @@ -#include <stdint.h> -#include <stdlib.h> #include <stdio.h> -#include <string.h> #include <assert.h> #include "nlr.h" @@ -1,3 +1,4 @@ +#include <stdbool.h> #include <stdio.h> #include <stdarg.h> #include <string.h> |