feat(freertos): add thread local private "errno"

This commit is contained in:
Dong Heng
2020-03-12 18:55:57 +08:00
parent ba3110798c
commit 99de07db83
11 changed files with 109 additions and 2 deletions

View File

@ -17,6 +17,8 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#define ERRNO_TLS_INDEX (configNUM_THREAD_LOCAL_STORAGE_POINTERS - 1)
static struct _reent impure_data;
struct _reent *_global_impure_ptr = &impure_data;
@ -44,3 +46,8 @@ struct _reent *__getreent()
#endif
return _global_impure_ptr;
}
int *__errno(void)
{
return (int *)pvTaskGetThreadLocalStorageBufferPointer(NULL, ERRNO_TLS_INDEX);
}

View File

@ -128,10 +128,15 @@ NVIC value of 255. */
#define configUSE_NEWLIB_REENTRANT 1
#endif
/**
* 0: LwIP
* 1: pthread (optional)
* 2: errno
*/
#ifdef CONFIG_ENABLE_PTHREAD
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 2
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 3
#else
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 1
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 2
#endif
#define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS 1