File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -136,6 +136,12 @@ __env_unlock (struct _reent * ptr)
136136#include <errno.h>
137137#include <sys/reent.h>
138138
139+ #if defined(__DYNAMIC_REENT__ )
140+ // Helps to keep code similar between dynamic and non-dynamic.
141+ #undef _reent_ptr
142+ struct _reent * _reent_ptr ;
143+ #endif
144+
139145#define XT_NUM_CLIB_LOCKS (_MAX_LOCK + FOPEN_MAX)
140146
141147typedef TX_MUTEX * _Rmtx ;
@@ -209,6 +215,31 @@ _Mtxunlock (_Rmtx * mtx)
209215
210216#endif /* XSHAL_CLIB == XTHAL_CLIB_XCLIB */
211217
218+ #if defined(__DYNAMIC_REENT__ )
219+ /**************************************************************************/
220+ /* Return libc context pointer for current thread. Overrides weak */
221+ /* version in libc. Until real threads are active, use the libc's */
222+ /* global reent struct. */
223+ /**************************************************************************/
224+ struct _reent *
225+ __getreent (void )
226+ {
227+ TX_THREAD * thread_ptr = _tx_thread_current_ptr ;
228+
229+ if (thread_ptr ) {
230+ return & (thread_ptr -> tx_thread_clib_reent );
231+ }
232+
233+ #if XSHAL_CLIB == XTHAL_CLIB_XCLIB
234+ extern struct _reent g_reent ; /* from xclib */
235+ return & g_reent ;
236+ #endif
237+ #if XSHAL_CLIB == XTHAL_CLIB_NEWLIB
238+ extern struct _reent * _impure_ptr ; /* from newlib */
239+ return _impure_ptr ;
240+ #endif
241+ }
242+ #endif
212243
213244/**************************************************************************/
214245/* _sbrk_r - heap allocator. This function is called when the memory */
You can’t perform that action at this time.
0 commit comments