esp32: Support app management and thread (#1350)

Support app management and thread on esp-idf platform:
- Fix compile issues when app management is enabled
- Add missing thread related APIs
This commit is contained in:
dongheng 2022-08-02 16:37:55 +08:00 committed by GitHub
parent bf28030993
commit b75ae3363d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -44,6 +44,25 @@ os_mutex_init(korp_mutex *mutex)
return pthread_mutex_init(mutex, NULL);
}
int
os_recursive_mutex_init(korp_mutex *mutex)
{
int ret;
pthread_mutexattr_t mattr;
assert(mutex);
ret = pthread_mutexattr_init(&mattr);
if (ret)
return BHT_ERROR;
pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
ret = pthread_mutex_init(mutex, &mattr);
pthread_mutexattr_destroy(&mattr);
return ret == 0 ? BHT_OK : BHT_ERROR;
}
int
os_mutex_destroy(korp_mutex *mutex)
{
@ -206,3 +225,9 @@ os_cond_signal(korp_cond *cond)
{
return pthread_cond_signal(cond);
}
int
os_cond_broadcast(korp_cond *cond)
{
return pthread_cond_broadcast(cond);
}

View File

@ -17,6 +17,7 @@
#include <math.h>
#include <unistd.h>
#include <pthread.h>
#include <arpa/inet.h>
#include "esp_pthread.h"
#include "esp_timer.h"