Skip to content

pkg/lua: Better Lua-RIOT integration - #9153

Merged
danpetry merged 2 commits into
RIOT-OS:masterfrom
jcarrano:lua-on-riot
Jul 2, 2018
Merged

pkg/lua: Better Lua-RIOT integration#9153
danpetry merged 2 commits into
RIOT-OS:masterfrom
jcarrano:lua-on-riot

Conversation

@jcarrano

@jcarrano jcarrano commented May 18, 2018

Copy link
Copy Markdown
Contributor

Better integration of the Lua interpreter with RIOT

The main idea behind this PR is that interpreted code should never be allowed to crash the host application. A secondary goal is to cover the majority of use cases in a few simple API calls, to remove the required boilerplate and make it easier to use the Lua package correctly.

  • The lua intepreter itself, with some custom modifications:
    • Patches to reduce C-stack usage.
    • Modifications to the test module to enable it to work on RIOT.
    • The vanilla module loader is disabled as it is too dependent on files and dynamic loading.
  • A new module loader intended to load source code and C-modules built-into the application.
  • A custom memory allocator based on TLSF. This allows to limit the memory that Lua can consume and to not have memory leaks in case of an interpreter crash.
  • A panic handler based on setjmp()/longjmp(). Thus, in case of a irrecoverable failure in the interpreter, control returns to the host application (by default, lua calls abort())
  • An example with an interactive Lua REPL.
  • Procedures to easily launch Lua and handle errors.

Note that only 32 bit CPUs will be supported.

Future work

The next PRs will focus on build system integration (i.e. being able to compile %.lua into an application).

About the Lua patches

I'm patching lua, in a way that is perfectly compatible with the unmodified code. I'm running the test suite, and it passes. Patches are still patches, and they will never get merged into upstream lua, simply because the Lua people don't accept outside submissions (check the FAQ for more info). This is a reality we have to accept. Other projects do the same, they apply their own modifications.

Issues/PRs references

Extends: #8847
Depends on: #9090 #9006 #9244

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants