Add Newlib dynamic reentrancy #496
Merged
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.
Description
Currently, when
configUSE_NEWLIB_REENTRANTis enabled, FreeRTOS will update Newlibs_impure_ptron every context switch to point to the current task'sreentstruct. However, this behavior is no longer valid for SMP due to the fact that two or more cores can switch contexts, thus leading to a corrupted_impure_ptr(i.e., multiple cores cannot share the same_impure_ptr.Newlib provides a
__DYNAMIC_REENT__feature where all newlib functions will call a__getreent()function to get the required reentrancy structure instead of referring to the_impure_ptr. In case of FreeRTOS, it should just return the current core's current task'sreentstruct.This commit adds the following changes:
configNEWLIB_REENTRANT_IS_DYNAMICoption to enable Newlib dynamic reentrancy support in FreeRTOS SMP_impure_ptris no longer modified by FreeRTOS whenconfigNEWLIB_REENTRANT_IS_DYNAMICis enabled__getreent()(probably somewhere infreertos_tasks_c_additions.h. The function could look something like the following: