Skip to content

general: find method to globally change shared data structures (shell commands, device parameters, network interfaces, ...) #4290

@kaspar030

Description

@kaspar030

We have many places where it would be really nice to add an entry to a shared array, from any file.

Think auto_init, shell_commands, device driver parameters, network interfaces, sensors, libc initializers, ...

I really appreciate that we haven't chosen to go libc's route of using the linker to sort these things out.
Still, I think that the current pile of hacks will get harder to maintain the more features RIOT gets.

I'm trying to come up with a nice way to be able to add entries to a global, shared array (per type).
I think all of the above can efficiently be modeled using const arrays of structs.

Something like:

in sys/random/sc_random.c:

SHELL_COMMAND { "random_init", function, ... }

in sys/gnrc/blah.c:

SHELL_COMMAND { "gnrc_print_blah", function, ... }

ends up as, e.g., bin/include/shell_commands_array.h:

shell_command_t shell_commands[] = {
  { "random_init", function, ... },
  { "gnrc_print_blah", function, ... },
}

IMHO, if we do this right, we can reuse it for all of the above "lists".
But:

  • C can't do it by itself
  • generated code sucks
  • ...

Opinions?

Metadata

Metadata

Assignees

Labels

Discussion: RFCThe issue/PR is used as a discussion starting point about the item of the issue/PRState: don't staleState: Tell state-bot to ignore this issueType: new featureThe issue requests / The PR implemements a new feature for RIOT

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions