1 #include <lib/sync/mutex.h> 2 #include <threads.h> 3 mtx_trylock(mtx_t * m)4int mtx_trylock(mtx_t* m) { 5 zx_status_t status = sync_mutex_trylock((sync_mutex_t*)&m->__i); 6 switch (status) { 7 default: 8 return thrd_error; 9 case 0: 10 return thrd_success; 11 case ZX_ERR_BAD_STATE: 12 return thrd_busy; 13 } 14 } 15