Skip to content

core: add DEFAULT_APP_ENTRY to select main() function#8533

Closed
jia200x wants to merge 1 commit into
RIOT-OS:masterfrom
jia200x:app_entry_point
Closed

core: add DEFAULT_APP_ENTRY to select main() function#8533
jia200x wants to merge 1 commit into
RIOT-OS:masterfrom
jia200x:app_entry_point

Conversation

@jia200x

@jia200x jia200x commented Feb 7, 2018

Copy link
Copy Markdown
Member

Contribution description

This PR/RFC adds a mechanism to change the default entry point to the user main function.
To change main entry point simply define DEFAULT_APP_ENTRY to a different function (by default, will call main() ).

Why?

I found this use cases:

  • For JavaScript apps (sys/js: initial support of RIOT <-> javascript API mapping #7796), the main() function is (somehow) just an event_loop() call and could be a common js_main() inside sys/js folder.
  • For Arduino support, we could have an arduino_main() that handles setup() and loop() functions
  • If at some point we add an App framework (provide custom setup, loop, handlers, whatever), we won't need to touch core files.

I also added a mechanism to print the name of the function, which I'm still not 100% sure if it's the way to go (message should still be there?, etc).

All feedback will be really appreciated!

@jia200x jia200x added Area: core Area: RIOT kernel. Handle PRs marked with this with care! Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR labels Feb 7, 2018
Comment thread core/kernel_init.c Outdated
LOG_INFO("main(): This is RIOT! (Version: " RIOT_VERSION ")\n");

LOG_INFO(DEFAULT_APP_ENTRY_NAME "(): This is RIOT! (Version: " RIOT_VERSION ")\n");
main();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@kaspar030

Copy link
Copy Markdown
Contributor

I don't quite agree with the use cases. Using this define, one other function can be selected (instead of main).

This could simple be solved by the corresponding modules just defining "main()", instead of an application.

@tcschmidt

Copy link
Copy Markdown
Member

@jia200x do you agree with the objections of @kaspar030 or shall we ask for another review?

@jia200x

jia200x commented Jun 6, 2018

Copy link
Copy Markdown
Member Author

@tcschmidt I agree. Let's close this PR and continue in favour of #9105

@jia200x jia200x closed this Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: core Area: RIOT kernel. Handle PRs marked with this with care! Discussion: RFC The issue/PR is used as a discussion starting point about the item of the issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants