Skip to content

Commit dbaea72

Browse files
committed
Merge branch 'bugfix/revisit_pthread_once' into 'master'
pthread: fix pthread_once behavior, if mux (handle) is in external PSRAM See merge request idf/esp-idf!1972
2 parents aedb807 + 48e8171 commit dbaea72

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

components/pthread/pthread.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -335,14 +335,16 @@ int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
335335
return EINVAL;
336336
}
337337

338-
// Check if once_control belongs to internal DRAM for uxPortCompare to succeed
339-
if (!esp_ptr_internal(once_control)) {
340-
ESP_LOGE(TAG, "%s: once_control should belong to internal DRAM region!", __FUNCTION__);
341-
return EINVAL;
342-
}
343-
344338
uint32_t res = 1;
345-
uxPortCompareSet((uint32_t *) &once_control->init_executed, 0, &res);
339+
#if defined(CONFIG_SPIRAM_SUPPORT)
340+
if (esp_ptr_external_ram(once_control)) {
341+
uxPortCompareSetExtram((uint32_t *) &once_control->init_executed, 0, &res);
342+
} else {
343+
#endif
344+
uxPortCompareSet((uint32_t *) &once_control->init_executed, 0, &res);
345+
#if defined(CONFIG_SPIRAM_SUPPORT)
346+
}
347+
#endif
346348
// Check if compare and set was successful
347349
if (res == 0) {
348350
ESP_LOGV(TAG, "%s: call init_routine %p", __FUNCTION__, once_control);

0 commit comments

Comments
 (0)