Skip to content

Allow Unix variant to override MICROPY_EVENT_POLL_HOOK #8278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

dlech
Copy link
Contributor

@dlech dlech commented Feb 8, 2022

This allows unix variants to extend or replace more config options:

  • extend builtin modules
  • extend root pointers
  • replace event poll hook

@dlech dlech force-pushed the unix-variant-config branch from 15a4349 to b749687 Compare February 8, 2022 16:28
@dlech
Copy link
Contributor Author

dlech commented Feb 8, 2022

https://github.com/micropython/micropython/runs/5112540065?check_suite_focus=true#step:6:15

There seems to be a bug in uncrustify, so we can either have proper syntax with bad formatting:

#define MICROPY_PORT_ROOT_POINTERS \
    const char *readline_hist[50]; \
    void *mmap_region_head; \
    MICROPY_BLUETOOTH_ROOT_POINTERS \
        MICROPY_VARIANT_ROOT_POINTERS \

Or an extra semicolon with proper formatting:

#define MICROPY_PORT_ROOT_POINTERS \
    const char *readline_hist[50]; \
    void *mmap_region_head; \
    MICROPY_BLUETOOTH_ROOT_POINTERS; \
    MICROPY_VARIANT_ROOT_POINTERS \

@stinos
Copy link
Contributor

stinos commented Feb 8, 2022

Related #8144 i.e. it's going to take many more PRs like this before all options are wrapped and everyone is satisfied :)

@dlech dlech force-pushed the unix-variant-config branch from b749687 to 1e0cecf Compare February 9, 2022 16:35
@jimmo
Copy link
Member

jimmo commented Apr 21, 2022

@dlech @stinos I think I'd prefer to make this work in a similar fashion to MP_REGISTER_MODULE (i.e. also add MP_REGISTER_ROOT_POINTER). See #8566 for the first step in deprecating MICROPY_PORT_BUILTIN_MODULES

That doesn't address MICROPY_EVENT_POLL_HOOK (although perhaps it could?) but also the broader issue raised in #8144 needs more thought.

@stinos
Copy link
Contributor

stinos commented Apr 21, 2022

I'd prefer to make this work in a similar fashion to MP_REGISTER_MODULE (i.e. also add MP_REGISTER_ROOT_POINTER).

That sounds good

@dlech
Copy link
Contributor Author

dlech commented Apr 22, 2022

That doesn't address MICROPY_EVENT_POLL_HOOK (although perhaps it could?)

This could be quite tricky to get right. As an example, here is our most complicated implementation currently: https://github.com/pybricks/pybricks-micropython/blob/f69bd694ba481563c980e09fae41b60c0ecea4fc/bricks/virtualhub/mp_port.c#L143-L185

Just allowing to override MICROPY_EVENT_POLL_HOOK seems like the simplest solution.

@dlech
Copy link
Contributor Author

dlech commented Jul 18, 2022

I have dropped the commits for registering extra modules and root pointers since those have been solved another way.

The remaining commit for overriding MICROPY_EVENT_POLL_HOOK is still needed and has been rebased.

@dlech dlech changed the title Unix variant config improvements Allow Unix variant to override MICROPY_EVENT_POLL_HOOK Jul 18, 2022
This allows variants to supply their own `MICROPY_EVENT_POLL_HOOK`.

Signed-off-by: David Lechner <david@pybricks.com>
@dlech dlech force-pushed the unix-variant-config branch from c6e5ec3 to 6af100e Compare July 18, 2022 18:43
@dpgeorge
Copy link
Member

Allowing to override MICROPY_EVENT_POLL_HOOK seems reasonable. Merged in 03fb671

@dpgeorge dpgeorge closed this Jul 19, 2022
@dlech dlech deleted the unix-variant-config branch July 19, 2022 01:30
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Aug 29, 2024
Now, try_lock (SPI & I2C) & begin_transaction (display bus core) will check
that the related objects are still valid first; if they are not,
the lock/begin transaction will fail by returning false, rather than
"other things" such as raising a Python exception where it is not
permitted, accessing invalid memory, etc.

Closes micropython#8278 and Closes micropython#9426
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants