mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-08-06 07:00:05 +08:00
Revert "Merge branch 'feature/support_gcc_v8.x' into 'master'"
This reverts merge request !1539
This commit is contained in:
53
components/freertos/port/esp8266/impure.c
Normal file
53
components/freertos/port/esp8266/impure.c
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright 2018-2019 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <reent.h>
|
||||
|
||||
#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;
|
||||
|
||||
struct _reent *__getreent()
|
||||
{
|
||||
#if configUSE_NEWLIB_REENTRANT == 1
|
||||
/*
|
||||
* Locking mutex(only mutex, not ISR mutex) at the following three
|
||||
* state may cause OS death. So we use a extra _reent data instead
|
||||
* of task private reent data.
|
||||
*
|
||||
* But although at the state none of "taskSCHEDULER_RUNNING", exception
|
||||
* can cause CPU swicth context, then Locking mutex may cause OS death.
|
||||
* So we command that use ets_printf(ROM function) instead of "printf"
|
||||
* at exception and system kernal critical state.
|
||||
*/
|
||||
if (xPortInIsrContext()
|
||||
|| !xTaskGetCurrentTaskHandle()
|
||||
|| xTaskGetSchedulerState() != taskSCHEDULER_RUNNING)
|
||||
return &impure_data;
|
||||
|
||||
/*
|
||||
* When scheduler starts, _global_impure_ptr = pxCurrentTCB->xNewLib_reent.
|
||||
*/
|
||||
#endif
|
||||
return _global_impure_ptr;
|
||||
}
|
||||
|
||||
int *__errno(void)
|
||||
{
|
||||
return (int *)pvTaskGetThreadLocalStorageBufferPointer(NULL, ERRNO_TLS_INDEX);
|
||||
}
|
@ -133,7 +133,11 @@ NVIC value of 255. */
|
||||
* 1: pthread (optional)
|
||||
* 2: errno
|
||||
*/
|
||||
#ifdef CONFIG_ENABLE_PTHREAD
|
||||
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 3
|
||||
#else
|
||||
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 2
|
||||
#endif
|
||||
#define configTHREAD_LOCAL_STORAGE_DELETE_CALLBACKS 1
|
||||
|
||||
/* add this to dump task stack information */
|
||||
|
@ -42,11 +42,15 @@ extern "C" {
|
||||
#include "xtensa_rtos.h"
|
||||
|
||||
#if defined(configUSE_NEWLIB_REENTRANT) && configUSE_NEWLIB_REENTRANT == 1
|
||||
#ifndef CONFIG_NEWLIB_LIBRARY_CUSTOMER
|
||||
#include "esp_newlib.h"
|
||||
|
||||
#define _impure_ptr _global_impure_ptr
|
||||
|
||||
#undef _REENT_INIT_PTR
|
||||
#define _REENT_INIT_PTR(p) esp_reent_init(p)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Port specific definitions.
|
||||
|
Reference in New Issue
Block a user