Repository navigation
examples/nxflat: Add tests of __thread and thread_local variables. - #3880
Merged
Merged
Conversation
xiaoxiang781216
approved these changes
Oct 19, 2026
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
CI run: https://github.com/apache/nuttx-apps/actions/runs/39231789693 |
tls has a __thread variable without an initial value, one with an initial value, and a struct whose template holds a string pointer and a data pointer. The main thread and a second thread each check the initial values and change them. Each thread must not see the changes of the other one. tlsxx does the same with a C++ thread_local object with a constructor, and with the static thread_local member of a class template. Each thread must construct its own objects at their first use. The member of the template is in COMDAT section groups. tlsxx needs CONFIG_HAVE_CXX. With a toolchain that emulates TLS, a module imports __emutls_get_address() from the base code, and the generated symbol table exports it. The checks of the second thread pass only if the base code keeps a copy of each variable per thread. The libgcc of such a toolchain keeps one copy for all threads. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
CI run: https://github.com/apache/nuttx-apps/actions/runs/39310472352 |
🔗 Cross-repo PR dependenciesThe read-only Build run reported the following dependent PR(s) and fetched head SHA(s):
CI run: https://github.com/apache/nuttx-apps/actions/runs/39339269946 |
acassis
approved these changes
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add two NXFLAT test modules.
tlshas a__threadvariable without an initial value, one with an initial value, and a struct whose template holds a string pointer and a data pointer.tlsxxhas a C++thread_localobject with a constructor and the staticthread_localmember of a class template. In each module, the main thread and a second thread check the initial values, change them, and check that the other thread does not see the change.tlsxxneedsCONFIG_HAVE_CXX.The module imports
__emutls_get_address(), and the symbol table thatmksymtab.shgenerates from the thunks exports it, so the example needs no other change.Impact
Two more modules in the ROMFS of examples/nxflat when pthreads are enabled (
tlsxxalso needsCONFIG_HAVE_CXX).Testing
See apache/nuttx#20805.
tlsxxneeds that PR: with ldnxflat of master,exec()oftlsxxfails. The checks of the second thread need a base code that keeps a copy of each__threadvariable per thread (#20723). eagle100:nxflat builds with the new module.tools/checkpatch.sh -c -u -m -gpasses.depends-on: [apache/nuttx/pull/20805 apache/nuttx/pull/20723]