mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-07-15 08:32:42 +08:00
feat(newlib): Add newlib platform function
This commit is contained in:
@ -77,6 +77,17 @@ extern "C" {
|
||||
#include <xtensa/xtruntime.h>
|
||||
#include "xtensa_rtos.h"
|
||||
|
||||
#if defined(configUSE_NEWLIB_REENTRANT) && configUSE_NEWLIB_REENTRANT == 1
|
||||
#if defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NORMAL) || defined(CONFIG_NEWLIB_LIBRARY_LEVEL_NANO)
|
||||
#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.
|
||||
*
|
||||
|
44
components/freertos/port/impure.c
Normal file
44
components/freertos/port/impure.c
Normal file
@ -0,0 +1,44 @@
|
||||
// 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 "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
static struct _reent impure_data;
|
||||
struct _reent *_global_impure_ptr = &impure_data;
|
||||
|
||||
struct _reent *__getreent()
|
||||
{
|
||||
extern char _xt_isr_status;
|
||||
|
||||
/*
|
||||
* 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 (_xt_isr_status
|
||||
|| !xTaskGetCurrentTaskHandle()
|
||||
|| xTaskGetSchedulerState() != taskSCHEDULER_RUNNING)
|
||||
return &impure_data;
|
||||
|
||||
/*
|
||||
* When scheduler starts, _global_impure_ptr = pxCurrentTCB->xNewLib_reent.
|
||||
*/
|
||||
return _global_impure_ptr;
|
||||
}
|
Reference in New Issue
Block a user