]> granicus.if.org Git - esp-idf/commitdiff
pthread: fix pthread_once behavior, if mux (handle) is in external PSRAM
authorMahavir Jain <mahavir@espressif.com>
Fri, 23 Feb 2018 09:19:24 +0000 (14:49 +0530)
committerMahavir Jain <mahavir@espressif.com>
Fri, 23 Feb 2018 09:21:05 +0000 (14:51 +0530)
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
components/pthread/pthread.c

index 8083947e4e8475e798be891e7586888184aba270..0ce185425b755b389debc51ef94866706b516241 100644 (file)
@@ -335,14 +335,16 @@ int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
         return EINVAL;
     }
 
-    // Check if once_control belongs to internal DRAM for uxPortCompare to succeed
-    if (!esp_ptr_internal(once_control)) {
-        ESP_LOGE(TAG, "%s: once_control should belong to internal DRAM region!", __FUNCTION__);
-        return EINVAL;
-    }
-
     uint32_t res = 1;
-    uxPortCompareSet((uint32_t *) &once_control->init_executed, 0, &res);
+#if defined(CONFIG_SPIRAM_SUPPORT)
+    if (esp_ptr_external_ram(once_control)) {
+        uxPortCompareSetExtram((uint32_t *) &once_control->init_executed, 0, &res);
+    } else {
+#endif
+        uxPortCompareSet((uint32_t *) &once_control->init_executed, 0, &res);
+#if defined(CONFIG_SPIRAM_SUPPORT)
+    }
+#endif
     // Check if compare and set was successful
     if (res == 0) {
         ESP_LOGV(TAG, "%s: call init_routine %p", __FUNCTION__, once_control);