mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/pthread_fixes' into 'master'
pthread fixes Closes IDFGH-1437 See merge request espressif/esp-idf!5646
This commit is contained in:
commit
8dbe1f024e
@ -3,6 +3,16 @@ idf_component_register(SRCS "pthread.c"
|
||||
"pthread_local_storage.c"
|
||||
INCLUDE_DIRS include)
|
||||
|
||||
if(GCC_NOT_5_2_0)
|
||||
set(extra_link_flags "-u pthread_include_pthread_impl")
|
||||
list(APPEND extra_link_flags "-u pthread_include_pthread_cond_impl")
|
||||
list(APPEND extra_link_flags "-u pthread_include_pthread_local_storage_impl")
|
||||
endif()
|
||||
|
||||
if(CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP)
|
||||
target_link_libraries(${COMPONENT_LIB} "-Wl,--wrap=vPortCleanUpTCB")
|
||||
endif()
|
||||
|
||||
if(extra_link_flags)
|
||||
target_link_libraries(${COMPONENT_LIB} INTERFACE "${extra_link_flags}")
|
||||
endif()
|
||||
|
@ -1,46 +1,46 @@
|
||||
menu "PThreads"
|
||||
|
||||
config ESP32_PTHREAD_TASK_PRIO_DEFAULT
|
||||
config PTHREAD_TASK_PRIO_DEFAULT
|
||||
int "Default task priority"
|
||||
range 0 255
|
||||
default 5
|
||||
help
|
||||
Priority used to create new tasks with default pthread parameters.
|
||||
|
||||
config ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT
|
||||
config PTHREAD_TASK_STACK_SIZE_DEFAULT
|
||||
int "Default task stack size"
|
||||
default 3072
|
||||
help
|
||||
Stack size used to create new tasks with default pthread parameters.
|
||||
|
||||
config ESP32_PTHREAD_STACK_MIN
|
||||
config PTHREAD_STACK_MIN
|
||||
int "Minimum allowed pthread stack size"
|
||||
default 768
|
||||
help
|
||||
Minimum allowed pthread stack size set in attributes passed to pthread_create
|
||||
|
||||
choice ESP32_PTHREAD_TASK_CORE_DEFAULT
|
||||
choice PTHREAD_TASK_CORE_DEFAULT
|
||||
bool "Default pthread core affinity"
|
||||
default ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY
|
||||
default PTHREAD_DEFAULT_CORE_NO_AFFINITY
|
||||
depends on !FREERTOS_UNICORE
|
||||
help
|
||||
The default core to which pthreads are pinned.
|
||||
|
||||
config ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY
|
||||
config PTHREAD_DEFAULT_CORE_NO_AFFINITY
|
||||
bool "No affinity"
|
||||
config ESP32_DEFAULT_PTHREAD_CORE_0
|
||||
config PTHREAD_DEFAULT_CORE_0
|
||||
bool "Core 0"
|
||||
config ESP32_DEFAULT_PTHREAD_CORE_1
|
||||
config PTHREAD_DEFAULT_CORE_1
|
||||
bool "Core 1"
|
||||
endchoice
|
||||
|
||||
config ESP32_PTHREAD_TASK_CORE_DEFAULT
|
||||
config PTHREAD_TASK_CORE_DEFAULT
|
||||
int
|
||||
default -1 if ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY || FREERTOS_UNICORE
|
||||
default 0 if ESP32_DEFAULT_PTHREAD_CORE_0
|
||||
default 1 if ESP32_DEFAULT_PTHREAD_CORE_1
|
||||
default -1 if PTHREAD_DEFAULT_CORE_NO_AFFINITY || FREERTOS_UNICORE
|
||||
default 0 if PTHREAD_DEFAULT_CORE_0
|
||||
default 1 if PTHREAD_DEFAULT_CORE_1
|
||||
|
||||
config ESP32_PTHREAD_TASK_NAME_DEFAULT
|
||||
config PTHREAD_TASK_NAME_DEFAULT
|
||||
string "Default name of pthreads"
|
||||
default "pthread"
|
||||
help
|
||||
|
@ -11,3 +11,11 @@ COMPONENT_ADD_LDFLAGS := -lpthread
|
||||
ifdef CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP
|
||||
COMPONENT_ADD_LDFLAGS += -Wl,--wrap=vPortCleanUpTCB
|
||||
endif
|
||||
|
||||
ifeq ($(GCC_NOT_5_2_0), 1)
|
||||
# Forces the linker to include pthread implementation from this component,
|
||||
# instead of the weak implementations provided by libgcc.
|
||||
COMPONENT_ADD_LDFLAGS += -u pthread_include_pthread_impl
|
||||
COMPONENT_ADD_LDFLAGS += -u pthread_include_pthread_cond_impl
|
||||
COMPONENT_ADD_LDFLAGS += -u pthread_include_pthread_local_storage_impl
|
||||
endif # GCC_NOT_5_2_0
|
||||
|
@ -22,7 +22,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef PTHREAD_STACK_MIN
|
||||
#define PTHREAD_STACK_MIN CONFIG_ESP32_PTHREAD_STACK_MIN
|
||||
#define PTHREAD_STACK_MIN CONFIG_PTHREAD_STACK_MIN
|
||||
#endif
|
||||
|
||||
/** pthread configuration structure that influences pthread creation */
|
||||
|
@ -170,14 +170,14 @@ esp_err_t esp_pthread_get_cfg(esp_pthread_cfg_t *p)
|
||||
|
||||
static int get_default_pthread_core()
|
||||
{
|
||||
return CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT == -1 ? tskNO_AFFINITY : CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT;
|
||||
return CONFIG_PTHREAD_TASK_CORE_DEFAULT == -1 ? tskNO_AFFINITY : CONFIG_PTHREAD_TASK_CORE_DEFAULT;
|
||||
}
|
||||
|
||||
esp_pthread_cfg_t esp_pthread_get_default_config()
|
||||
{
|
||||
esp_pthread_cfg_t cfg = {
|
||||
.stack_size = CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT,
|
||||
.prio = CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT,
|
||||
.stack_size = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT,
|
||||
.prio = CONFIG_PTHREAD_TASK_PRIO_DEFAULT,
|
||||
.inherit_cfg = false,
|
||||
.thread_name = NULL,
|
||||
.pin_to_core = get_default_pthread_core()
|
||||
@ -233,10 +233,10 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
uint32_t stack_size = CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
||||
BaseType_t prio = CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT;
|
||||
uint32_t stack_size = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
||||
BaseType_t prio = CONFIG_PTHREAD_TASK_PRIO_DEFAULT;
|
||||
BaseType_t core_id = get_default_pthread_core();
|
||||
const char *task_name = CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT;
|
||||
const char *task_name = CONFIG_PTHREAD_TASK_NAME_DEFAULT;
|
||||
|
||||
esp_pthread_cfg_t *pthread_cfg = pthread_getspecific(s_pthread_cfg_key);
|
||||
if (pthread_cfg) {
|
||||
@ -256,7 +256,7 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
task_name = pthread_cfg->thread_name;
|
||||
}
|
||||
} else if (pthread_cfg->thread_name == NULL) {
|
||||
task_name = CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT;
|
||||
task_name = CONFIG_PTHREAD_TASK_NAME_DEFAULT;
|
||||
} else {
|
||||
task_name = pthread_cfg->thread_name;
|
||||
}
|
||||
@ -758,7 +758,7 @@ int pthread_attr_init(pthread_attr_t *attr)
|
||||
{
|
||||
if (attr) {
|
||||
/* Nothing to allocate. Set everything to default */
|
||||
attr->stacksize = CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
||||
attr->stacksize = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
||||
attr->detachstate = PTHREAD_CREATE_JOINABLE;
|
||||
return 0;
|
||||
}
|
||||
@ -769,7 +769,7 @@ int pthread_attr_destroy(pthread_attr_t *attr)
|
||||
{
|
||||
if (attr) {
|
||||
/* Nothing to deallocate. Reset everything to default */
|
||||
attr->stacksize = CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
||||
attr->stacksize = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT;
|
||||
attr->detachstate = PTHREAD_CREATE_JOINABLE;
|
||||
return 0;
|
||||
}
|
||||
@ -820,3 +820,8 @@ int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
|
||||
}
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* Hook function to force linking this file */
|
||||
void pthread_include_pthread_impl()
|
||||
{
|
||||
}
|
||||
|
@ -198,3 +198,8 @@ int pthread_cond_destroy(pthread_cond_t *cv)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Hook function to force linking this file */
|
||||
void pthread_include_pthread_cond_var_impl()
|
||||
{
|
||||
}
|
||||
|
@ -255,3 +255,8 @@ int pthread_setspecific(pthread_key_t key, const void *value)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Hook function to force linking this file */
|
||||
void pthread_include_pthread_local_storage_impl()
|
||||
{
|
||||
}
|
||||
|
@ -1,4 +1,11 @@
|
||||
# sdkconfig replacement configurations for deprecated options formatted as
|
||||
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
|
||||
|
||||
CONFIG_PTHREAD_STACK_MIN CONFIG_ESP32_PTHREAD_STACK_MIN
|
||||
CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT CONFIG_PTHREAD_TASK_PRIO_DEFAULT
|
||||
CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT
|
||||
CONFIG_ESP32_PTHREAD_STACK_MIN CONFIG_PTHREAD_STACK_MIN
|
||||
CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT CONFIG_PTHREAD_TASK_CORE_DEFAULT
|
||||
CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY
|
||||
CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 CONFIG_PTHREAD_DEFAULT_CORE_0
|
||||
CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 CONFIG_PTHREAD_DEFAULT_CORE_1
|
||||
CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT CONFIG_PTHREAD_TASK_NAME_DEFAULT
|
||||
|
@ -483,8 +483,8 @@ CONFIG_OPENSSL_ASSERT_EXIT=
|
||||
#
|
||||
# PThreads
|
||||
#
|
||||
CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5
|
||||
CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072
|
||||
CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5
|
||||
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072
|
||||
|
||||
#
|
||||
# SPI Flash driver
|
||||
|
Loading…
Reference in New Issue
Block a user