mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
change(pthread): changed pthread to not pull in init functions if not used
The pthread_init function would always get included in the binary, even when no pthread functions were used. This happens due to us using -u linker flags to force the linker to consider the pthread library, to ensure the weak pthread functions in the toolchain are overridden. By restructing the code to rely on lazy inits instead we can avoid using a init function, and therefor save some space. Closes https://github.com/espressif/esp-idf/issues/14213
This commit is contained in:
@@ -15,10 +15,21 @@
|
||||
#include <errno.h>
|
||||
#include "pthread.h"
|
||||
|
||||
static void *exit_task(void *args)
|
||||
{
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
esp_pthread_cfg_t config = esp_pthread_get_default_config();
|
||||
TEST_ASSERT_EQUAL(ESP_OK, esp_pthread_set_cfg(&config));
|
||||
|
||||
/* Needed to allocate the lazy allocated locks */
|
||||
pthread_t pthread_object = (pthread_t)NULL;
|
||||
TEST_ASSERT_EQUAL_INT(0, pthread_create(&pthread_object, NULL, exit_task, NULL));
|
||||
TEST_ASSERT_EQUAL_INT(0, pthread_join(pthread_object, NULL));
|
||||
|
||||
test_utils_record_free_mem();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user