MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / check_create

Function check_create

components/libc/cplusplus/cpp11/armclang/mutex.cpp:16–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14#include "tpl.h"
15
16static int check_create(volatile __ARM_TPL_mutex_t *__vm, bool recursive = false)
17{
18 if (__vm->data == 0)
19 {
20 uintptr_t mut_null = 0;
21 arm_tpl_mutex_struct *mutex_p = (arm_tpl_mutex_struct *)rt_malloc(sizeof(arm_tpl_mutex_struct));
22 if (mutex_p == nullptr) return -1;
23
24 if (recursive)
25 mutex_p->mutex = rt_mutex_create("mutexx", RT_IPC_FLAG_PRIO);
26 else
27 mutex_p->mutex = rt_mutex_create("mutexx", RT_IPC_FLAG_PRIO);
28
29 if (mutex_p->mutex == nullptr)
30 {
31 rt_free(mutex_p);
32 return -1;
33 }
34 mutex_p->type = recursive ? RECURSIVE : NORMAL;
35 uintptr_t mut_new = reinterpret_cast<uintptr_t>(mutex_p);
36 if (!atomic_compare_exchange_strong(&__vm->data, &mut_null, mut_new))
37 {
38 rt_mutex_delete(mutex_p->mutex);
39 rt_free(mutex_p);
40 }
41 }
42 return 0;
43}
44
45static int mutexLock(arm_tpl_mutex_struct *mutex_p, rt_tick_t timeOut)
46{

Callers 3

__ARM_TPL_mutex_lockFunction · 0.70
__ARM_TPL_mutex_trylockFunction · 0.70

Calls 4

rt_mallocFunction · 0.85
rt_mutex_createFunction · 0.85
rt_freeFunction · 0.85
rt_mutex_deleteFunction · 0.85

Tested by

no test coverage detected