mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-25 09:42:35 +00:00
refactor(core): reformat newlib and pthread with astyle
This commit is contained in:
@@ -62,10 +62,9 @@ typedef struct {
|
||||
static SemaphoreHandle_t s_threads_mux = NULL;
|
||||
portMUX_TYPE pthread_lazy_init_lock = portMUX_INITIALIZER_UNLOCKED; // Used for mutexes and cond vars and rwlocks
|
||||
static SLIST_HEAD(esp_thread_list_head, esp_pthread_entry) s_threads_list
|
||||
= SLIST_HEAD_INITIALIZER(s_threads_list);
|
||||
= SLIST_HEAD_INITIALIZER(s_threads_list);
|
||||
static pthread_key_t s_pthread_cfg_key;
|
||||
|
||||
|
||||
static int pthread_mutex_lock_internal(esp_pthread_mutex_t *mux, TickType_t tmo);
|
||||
|
||||
static void esp_pthread_cfg_key_destructor(void *value)
|
||||
@@ -239,16 +238,16 @@ static UBaseType_t coreID_to_AffinityMask(BaseType_t core_id)
|
||||
#endif
|
||||
|
||||
static BaseType_t pthread_create_freertos_task_with_caps(TaskFunction_t pxTaskCode,
|
||||
const char * const pcName,
|
||||
const configSTACK_DEPTH_TYPE usStackDepth,
|
||||
void * const pvParameters,
|
||||
UBaseType_t uxPriority,
|
||||
BaseType_t core_id,
|
||||
UBaseType_t uxStackMemoryCaps,
|
||||
TaskHandle_t * const pxCreatedTask)
|
||||
const char * const pcName,
|
||||
const configSTACK_DEPTH_TYPE usStackDepth,
|
||||
void * const pvParameters,
|
||||
UBaseType_t uxPriority,
|
||||
BaseType_t core_id,
|
||||
UBaseType_t uxStackMemoryCaps,
|
||||
TaskHandle_t * const pxCreatedTask)
|
||||
{
|
||||
#if CONFIG_SPIRAM
|
||||
#if CONFIG_FREERTOS_SMP
|
||||
#if CONFIG_FREERTOS_SMP
|
||||
return prvTaskCreateDynamicAffinitySetWithCaps(pxTaskCode,
|
||||
pcName,
|
||||
usStackDepth,
|
||||
@@ -257,7 +256,7 @@ static BaseType_t pthread_create_freertos_task_with_caps(TaskFunction_t pxTaskCo
|
||||
coreID_to_AffinityMask(core_id),
|
||||
uxStackMemoryCaps,
|
||||
pxCreatedTask);
|
||||
#else
|
||||
#else
|
||||
return prvTaskCreateDynamicPinnedToCoreWithCaps(pxTaskCode,
|
||||
pcName,
|
||||
usStackDepth,
|
||||
@@ -266,7 +265,7 @@ static BaseType_t pthread_create_freertos_task_with_caps(TaskFunction_t pxTaskCo
|
||||
core_id,
|
||||
uxStackMemoryCaps,
|
||||
pxCreatedTask);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
return xTaskCreatePinnedToCore(pxTaskCode,
|
||||
pcName,
|
||||
@@ -279,7 +278,7 @@ static BaseType_t pthread_create_freertos_task_with_caps(TaskFunction_t pxTaskCo
|
||||
}
|
||||
|
||||
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine) (void *), void *arg)
|
||||
void *(*start_routine)(void *), void *arg)
|
||||
{
|
||||
TaskHandle_t xHandle = NULL;
|
||||
|
||||
@@ -360,13 +359,13 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
pthread->task_arg = task_arg;
|
||||
|
||||
BaseType_t res = pthread_create_freertos_task_with_caps(&pthread_task_func,
|
||||
task_name,
|
||||
stack_size,
|
||||
task_arg,
|
||||
prio,
|
||||
core_id,
|
||||
stack_alloc_caps,
|
||||
&xHandle);
|
||||
task_name,
|
||||
stack_size,
|
||||
task_arg,
|
||||
prio,
|
||||
core_id,
|
||||
stack_alloc_caps,
|
||||
&xHandle);
|
||||
|
||||
if (res != pdPASS) {
|
||||
ESP_LOGE(TAG, "Failed to create task!");
|
||||
@@ -549,7 +548,7 @@ int pthread_cancel(pthread_t thread)
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int sched_yield( void )
|
||||
int sched_yield(void)
|
||||
{
|
||||
vTaskDelay(0);
|
||||
return 0;
|
||||
@@ -594,8 +593,8 @@ int pthread_once(pthread_once_t *once_control, void (*init_routine)(void))
|
||||
static int mutexattr_check(const pthread_mutexattr_t *attr)
|
||||
{
|
||||
if (attr->type != PTHREAD_MUTEX_NORMAL &&
|
||||
attr->type != PTHREAD_MUTEX_RECURSIVE &&
|
||||
attr->type != PTHREAD_MUTEX_ERRORCHECK) {
|
||||
attr->type != PTHREAD_MUTEX_RECURSIVE &&
|
||||
attr->type != PTHREAD_MUTEX_ERRORCHECK) {
|
||||
return EINVAL;
|
||||
}
|
||||
return 0;
|
||||
@@ -686,7 +685,7 @@ static int pthread_mutex_lock_internal(esp_pthread_mutex_t *mux, TickType_t tmo)
|
||||
}
|
||||
|
||||
if ((mux->type == PTHREAD_MUTEX_ERRORCHECK) &&
|
||||
(xSemaphoreGetMutexHolder(mux->sem) == xTaskGetCurrentTaskHandle())) {
|
||||
(xSemaphoreGetMutexHolder(mux->sem) == xTaskGetCurrentTaskHandle())) {
|
||||
return EDEADLK;
|
||||
}
|
||||
|
||||
@@ -740,8 +739,8 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *timeo
|
||||
|
||||
struct timespec currtime;
|
||||
clock_gettime(CLOCK_REALTIME, &currtime);
|
||||
TickType_t tmo = ((timeout->tv_sec - currtime.tv_sec)*1000 +
|
||||
(timeout->tv_nsec - currtime.tv_nsec)/1000000)/portTICK_PERIOD_MS;
|
||||
TickType_t tmo = ((timeout->tv_sec - currtime.tv_sec) * 1000 +
|
||||
(timeout->tv_nsec - currtime.tv_nsec) / 1000000) / portTICK_PERIOD_MS;
|
||||
|
||||
res = pthread_mutex_lock_internal((esp_pthread_mutex_t *)*mutex, tmo);
|
||||
if (res == EBUSY) {
|
||||
@@ -775,8 +774,8 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex)
|
||||
}
|
||||
|
||||
if (((mux->type == PTHREAD_MUTEX_RECURSIVE) ||
|
||||
(mux->type == PTHREAD_MUTEX_ERRORCHECK)) &&
|
||||
(xSemaphoreGetMutexHolder(mux->sem) != xTaskGetCurrentTaskHandle())) {
|
||||
(mux->type == PTHREAD_MUTEX_ERRORCHECK)) &&
|
||||
(xSemaphoreGetMutexHolder(mux->sem) != xTaskGetCurrentTaskHandle())) {
|
||||
return EPERM;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user