Skip to content

Commit

Permalink
Merge branch 'contrib/github_pr_14339' into 'master'
Browse files Browse the repository at this point in the history
Fix(pthread): Added linux port with empty functions to make pthread cxx example build. (GitHub PR)

Closes IDFGH-13424 and IDFGH-13433

See merge request espressif/esp-idf!32785
  • Loading branch information
0xjakob committed Aug 13, 2024
2 parents 50244f4 + d3ab90b commit d7ca8b9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
6 changes: 4 additions & 2 deletions components/pthread/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "linux")
# Make pthread component an empty interface lib referencing host pthread for Linux target
idf_component_register()
set(sources "port/linux/pthread.c")
idf_component_register(
SRCS ${sources}
INCLUDE_DIRS include)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${COMPONENT_LIB} INTERFACE Threads::Threads)
Expand Down
43 changes: 43 additions & 0 deletions components/pthread/port/linux/pthread.c
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
idf_component_register(SRCS "generic_build_test.c"
INCLUDE_DIRS ".")
INCLUDE_DIRS "."
PRIV_REQUIRES pthread)
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
#include <stddef.h>
#include "inttypes_ext.h"

#include "esp_pthread.h"

void app_main(void)
{
size_t size = 47;
printf("size is: %" PRIuSIZE "\n", size); // test IDF's PRIuSIZE

esp_pthread_cfg_t pthread_config = esp_pthread_get_default_config();
(void)pthread_config;
}

3 comments on commit d7ca8b9

@cristianfunes79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi I just pulled it from main and I don't see my name as contributor:

commit d7ca8b94c852052e3bc33292287ef4dd62c9eeb1 (HEAD -> master, origin/master, origin/HEAD)
Merge: 50244f4c79 d3ab90ba24
Author: Jakob Hasse <jakob.hasse@espressif.com>
Date:   Wed Aug 14 00:05:12 2024 +0800

    Merge branch 'contrib/github_pr_14339' into 'master'
    
    Fix(pthread): Added linux port with empty functions to make pthread cxx example build. (GitHub PR)
    
    Closes IDFGH-13424 and IDFGH-13433
    
    See merge request espressif/esp-idf!32785

@igrr
Copy link
Member

@igrr igrr commented on d7ca8b9 Aug 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cristianfunes79 d7ca8b9 is a merge commit. The commit you have authored is one of the two parent commits of the merge: d3ab90b.

@cristianfunes79
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cristianfunes79 d7ca8b9 is a merge commit. The commit you have authored is one of the two parent commits of the merge: d3ab90b.

I see it thanks!

Please sign in to comment.