Commit Graph

28 Commits

Author SHA1 Message Date
Alexander Steffen 55f33240f3 all: Use the name MicroPython consistently in comments
There were several different spellings of MicroPython present in comments,
when there should be only one.
2017-07-31 18:35:40 +10:00
Alexander Steffen 299bc62586 all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how
those should look like and instead point to existing files. However, not
all existing files follow the same scheme, sometimes omitting header guards
altogether, sometimes using non-standard names, making it easy to
accidentally pick a "wrong" example.

This commit ensures that all header files of the MicroPython project (that
were not simply copied from somewhere else) follow the same pattern, that
was already present in the majority of files, especially in the py folder.

The rules are as follows.

Naming convention:
* start with the words MICROPY_INCLUDED
* contain the full path to the file
* replace special characters with _

In addition, there are no empty lines before #ifndef, between #ifndef and
one empty line before #endif. #endif is followed by a comment containing
the name of the guard macro.

py/grammar.h cannot use header guards by design, since it has to be
included multiple times in a single C file. Several other files also do not
need header guards as they are only used internally and guaranteed to be
included only once:
* MICROPY_MPHALPORT_H
* mpconfigboard.h
* mpconfigport.h
* mpthreadport.h
* pin_defs_*.h
* qstrdefs*.h
2017-07-18 11:57:39 +10:00
stijn 2f0ce2a6f5 py: Cleanup use of global DEBUG preprocessor definition
The standard preprocessor definition to differentiate debug and non-debug
builds is NDEBUG, not DEBUG, so don't rely on the latter:
- just delete the use of it in objint_longlong.c as it has been stale code
  for years anyway (since commit [c4029e5]): SUFFIX isn't used anywhere.
- replace DEBUG with MICROPY_DEBUG_NLR in nlr.h: it is rarely used anymore
  so can be off by default
2017-04-30 14:28:37 +03:00
Damien George be3d7f91e5 py/nlr.h: Mark nlr_jump_fail as NORETURN. 2017-03-06 17:13:16 +11:00
Damien George 94238d4ae5 py/nlrsetjmp: Update to take into account new location of nlr_top.
It's now accessed via the MP_STATE_THREAD macro.
2016-06-28 11:28:52 +01:00
Damien George 999cedb90f py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.
This allows the mp_obj_t type to be configured to something other than a
pointer-sized primitive type.

This patch also includes additional changes to allow the code to compile
when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of
mp_uint_t, and various casts.
2015-11-29 14:25:35 +00:00
stijn 803264bb17 py: Guard against redef of nlr_push with DEBUG + MICROPY_NLR_SETJMP. 2015-03-03 14:34:40 +00:00
Paul Sokolovsky 3077fbff26 nlr: Add even more optional debugging logging.
Has to be enabled by manual editing, but at least it's there, as debugging
NLR issues may be weird.
2015-02-15 20:28:18 +03:00
Paul Sokolovsky e89cc13e5c nlr: If DEBUG, guard against recursive nlr_push().
Pushing same NLR record twice would lead to "infinite loop" in nlr_jump
(but more realistically, it will crash as soon as NLR record on stack is
overwritten).
2015-02-15 20:23:52 +03:00
Damien George b4b10fd350 py: Put all global state together in state structures.
This patch consolidates all global variables in py/ core into one place,
in a global structure.  Root pointers are all located together to make
GC tracing easier and more efficient.
2015-01-07 20:33:00 +00:00
Damien George 8a2347723e py: Move global variable nlr_top to one place, in a .c file.
This reduces dependency on assembler, and allows to consolidate global
variables in the future.
2015-01-01 21:47:58 +00:00
Damien George 51dfcb4bb7 py: Move to guarded includes, everywhere in py/ core.
Addresses issue #1022.
2015-01-01 20:32:09 +00:00
Damien George 2399aa03b8 py: Add NLR support for xtensa CPU. 2014-11-27 20:29:33 +00:00
Damien George 7860c2a68a py: Fix some macros defines; cleanup some includes. 2014-11-05 21:16:41 +00: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
Emmanuel Blot bf3366a48b Add missing “assert.h” file header inclusion from “nlr.h” 2014-06-19 18:47:38 +02:00
Damien George 04b9147e15 Add license header to (almost) all files.
Blanket wide to all .c and .h files.  Some files originating from ST are
difficult to deal with (license wise) so it was left out of those.

Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-05-03 23:27:38 +01:00
Paul Sokolovsky f54bcbf099 py, unix: Make "mpconfig.h" be first included, as other headers depend on it.
Specifically, nlr.h does.
2014-05-02 17:48:40 +03:00
Paul Sokolovsky e908591baa py: Abstract no-return attribute for functions a bit. 2014-04-30 05:35:18 +03:00
Paul Sokolovsky 851c856585 nlr.h: As we treat all warnings as errors, can't use #warning.
And this is not good.
2014-04-30 04:14:31 +03:00
Paul Sokolovsky 3a83b805fc nlr: Add implementation using setjmp/longjmp.
Having an optimized asm implementation is good, but if we want portability,
that's it.
2014-04-17 00:19:18 +03:00
Damien George 26cf55ae05 Add a check for NULL nlr_top in nlr_jump.
If no nlr_buf has been pushed, and an nlr_jump is called, then control
is transferred to nlr_jump_fail (which should bail out with a fatal
error).
2014-04-08 14:08:14 +00:00
Damien George ea13f407a3 py: Change nlr_jump to nlr_raise, to aid in debugging.
This does not affect code size or performance when debugging turned off.

To address issue #420.
2014-04-05 18:32:08 +01:00
Damien George 4b34c76fd6 Changes to get unix/ port compiling on Cygwin. 2014-04-03 23:51:16 +01:00
Paul Sokolovsky 82a165d9be nlr.h: Do proper arch selection, using the same tests as nlr*.S . 2014-03-01 10:05:33 +02:00
Damien 8b3a7c2237 Fix func decls with no arguments: () -> (void). 2013-10-23 20:20:17 +01:00
Damien 152568bcb6 NLR and Python exceptions work on the board. 2013-10-16 00:46:39 +01:00
Damien ce89a21ea4 Implement basic exception framework, and simple for loop. 2013-10-15 22:25:17 +01:00