mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
fix(pthread): Fix cxx pthread example build for linux platform
Closes https://github.com/espressif/esp-idf/pull/14339
This commit is contained in:
parent
5d285c15e4
commit
d3ab90ba24
@ -1,7 +1,9 @@
|
|||||||
idf_build_get_property(target IDF_TARGET)
|
idf_build_get_property(target IDF_TARGET)
|
||||||
if(${target} STREQUAL "linux")
|
if(${target} STREQUAL "linux")
|
||||||
# Make pthread component an empty interface lib referencing host pthread for Linux target
|
set(sources "port/linux/pthread.c")
|
||||||
idf_component_register()
|
idf_component_register(
|
||||||
|
SRCS ${sources}
|
||||||
|
INCLUDE_DIRS include)
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
target_link_libraries(${COMPONENT_LIB} INTERFACE Threads::Threads)
|
target_link_libraries(${COMPONENT_LIB} INTERFACE Threads::Threads)
|
||||||
|
43
components/pthread/port/linux/pthread.c
Normal file
43
components/pthread/port/linux/pthread.c
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* pthread port for Linux build
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "esp_pthread.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Creates a default pthread configuration based
|
||||||
|
* on the values set via menuconfig.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* A default configuration structure.
|
||||||
|
*/
|
||||||
|
esp_pthread_cfg_t esp_pthread_get_default_config(void)
|
||||||
|
{
|
||||||
|
esp_pthread_cfg_t cfg = {
|
||||||
|
.stack_size = CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT,
|
||||||
|
.prio = CONFIG_PTHREAD_TASK_PRIO_DEFAULT,
|
||||||
|
.inherit_cfg = false,
|
||||||
|
.thread_name = NULL,
|
||||||
|
.pin_to_core = 0,
|
||||||
|
.stack_alloc_caps = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_pthread_set_cfg(const esp_pthread_cfg_t *cfg)
|
||||||
|
{
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_pthread_get_cfg(esp_pthread_cfg_t *p)
|
||||||
|
{
|
||||||
|
memset(p, 0, sizeof(*p));
|
||||||
|
return ESP_ERR_NOT_FOUND;
|
||||||
|
}
|
@ -1,2 +1,3 @@
|
|||||||
idf_component_register(SRCS "generic_build_test.c"
|
idf_component_register(SRCS "generic_build_test.c"
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS "."
|
||||||
|
PRIV_REQUIRES pthread)
|
||||||
|
@ -8,8 +8,13 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include "inttypes_ext.h"
|
#include "inttypes_ext.h"
|
||||||
|
|
||||||
|
#include "esp_pthread.h"
|
||||||
|
|
||||||
void app_main(void)
|
void app_main(void)
|
||||||
{
|
{
|
||||||
size_t size = 47;
|
size_t size = 47;
|
||||||
printf("size is: %" PRIuSIZE "\n", size); // test IDF's PRIuSIZE
|
printf("size is: %" PRIuSIZE "\n", size); // test IDF's PRIuSIZE
|
||||||
|
|
||||||
|
esp_pthread_cfg_t pthread_config = esp_pthread_get_default_config();
|
||||||
|
(void)pthread_config;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user