Skip to content
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

Support per-core state using #[thread_local] #794

Closed
wants to merge 4 commits into from

Commits on Apr 15, 2024

  1. Support per-core state using #[thread_local]

    - Controlled by `thread_local` feature
    - Does not require nightly features, but using it does
    - Intercepts `__pre_init` to copy .tdata into the per-core state
    - Implements `__aeabi_read_tp` to returns per-core state for code compiler
      generates when accessing `thread_local` variables
    - Needs linker script support to set up the layout and symbols
    
    This is based on
    [picolibc](https://github.com/picolibc/picolibc/blob/58d6157cc2135df5043d62c3e89feedc20ffcd57/newlib/libc/picolib/machine/arm/read_tp.S#L71)'s
    support for TLS; its the only example I found of it for rp2040.
    jsgf committed Apr 15, 2024
    Configuration menu
    Copy the full SHA
    be5b9ea View commit details
    Browse the repository at this point in the history

Commits on Apr 20, 2024

  1. Add docs for per-core state.

    jsgf committed Apr 20, 2024
    Configuration menu
    Copy the full SHA
    5716506 View commit details
    Browse the repository at this point in the history

Commits on Apr 21, 2024

  1. Update asm:

    - for __eabi_read_tp, simplify to just directly load TLS_CORE_[01]
      as needed without the need for an indirection. This only uses r0
      and doesn't touch the stack.
    - Write the tdata copy in Rust, being careful to only use raw pointers.
      The generated asm is functionally identical to the hand-written asm.
    jsgf committed Apr 21, 2024
    Configuration menu
    Copy the full SHA
    70c1bb6 View commit details
    Browse the repository at this point in the history
  2. Add an example of per-core state

    FIXME: nightly only
    jsgf committed Apr 21, 2024
    Configuration menu
    Copy the full SHA
    5a547d0 View commit details
    Browse the repository at this point in the history