127127 #include <wolfssl/wolfcrypt/port/psa/psa.h>
128128#endif
129129
130+ #if defined(FREERTOS ) && defined(WOLFSSL_ESPIDF )
131+ #include <freertos/FreeRTOS.h>
132+ #include <freertos/task.h>
133+ /* The Espressif-specific platform include: */
134+ #include <pthread.h>
135+ #endif
130136
131137/* prevent multiple mutex initializations */
132138static volatile int initRefCount = 0 ;
@@ -3426,6 +3432,7 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
34263432
34273433#ifndef SINGLE_THREADED
34283434
3435+ /* Environment-specific multi-thread implementation check */
34293436#if defined(USE_WINDOWS_API ) && !defined(WOLFSSL_PTHREADS )
34303437 int wolfSSL_NewThread (THREAD_TYPE * thread ,
34313438 THREAD_CB cb , void * arg )
@@ -3724,7 +3731,8 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
37243731
37253732#endif /* WOLFSSL_COND */
37263733
3727- #elif defined(WOLFSSL_PTHREADS )
3734+ #elif defined(WOLFSSL_PTHREADS ) || \
3735+ (defined(FREERTOS ) && defined(WOLFSSL_ESPIDF ))
37283736
37293737 int wolfSSL_NewThread (THREAD_TYPE * thread ,
37303738 THREAD_CB cb , void * arg )
@@ -3738,18 +3746,18 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
37383746 return 0 ;
37393747 }
37403748
3741- #ifdef WOLFSSL_THREAD_NO_JOIN
3742- int wolfSSL_NewThreadNoJoin (THREAD_CB_NOJOIN cb , void * arg )
3743- {
3744- THREAD_TYPE thread ;
3745- int ret ;
3746- XMEMSET (& thread , 0 , sizeof (thread ));
3747- ret = wolfSSL_NewThread (& thread , cb , arg );
3748- if (ret == 0 )
3749- ret = pthread_detach (thread );
3750- return ret ;
3751- }
3752- #endif
3749+ #ifdef WOLFSSL_THREAD_NO_JOIN
3750+ int wolfSSL_NewThreadNoJoin (THREAD_CB_NOJOIN cb , void * arg )
3751+ {
3752+ THREAD_TYPE thread ;
3753+ int ret ;
3754+ XMEMSET (& thread , 0 , sizeof (thread ));
3755+ ret = wolfSSL_NewThread (& thread , cb , arg );
3756+ if (ret == 0 )
3757+ ret = pthread_detach (thread );
3758+ return ret ;
3759+ }
3760+ #endif
37533761
37543762 int wolfSSL_JoinThread (THREAD_TYPE thread )
37553763 {
@@ -3937,6 +3945,6 @@ char* mystrnstr(const char* s1, const char* s2, unsigned int n)
39373945 #endif /* __MACH__ */
39383946#endif /* WOLFSSL_COND */
39393947
3940- #endif
3948+ #endif /* Environment check */
39413949
3942- #endif /* SINGLE_THREADED */
3950+ #endif /* not SINGLE_THREADED */
0 commit comments